0

I'm new to databases and was doing installation for a software where we have to change following in maria db.

> mariadb-server-10.6  

> sudo mariadb -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mypassword';
    UPDATE mysql.user SET authentication_string = '' WHERE user = 'root';
    UPDATE mysql.user SET plugin = '' WHERE user = 'root';

I'm able to login into mariadb and ALTER password but when I perform Update I'm getting error.

ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

So was going through the documentation which state that we have to use ALTER user as now user is table instead of view

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [(none)]> use mysql;
MariaDB [mysql]> ALTER USER root SET authentication_string=''

Tried this and similar some combination but no luck

sandy560
  • 49
  • 1
  • 8
  • Does this answer your question? [ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them](https://stackoverflow.com/questions/64841185/error-1356-hy000-view-mysql-user-references-invalid-tables-or-columns-o) – danblack Mar 14 '23 at 09:20
  • @danblack Thanks for checking actually I had referred to same post and tried but still facing issue actually have to run all above commands otherwise the installation is failing but only password changes is working update command are failing – sandy560 Mar 14 '23 at 09:47
  • Below is the software installation link which I'm referring in point 5 they have mentioned https://www.tango-controls.org/community/forum/c/general/installation/installing-tango-934-on-ubuntu-lts-2004/ – sandy560 Mar 14 '23 at 09:49
  • Its unclear why the original document even thinks the other UPDATEs are needed. Ignore them. – danblack Mar 14 '23 at 10:10
  • Actually If I'm ignoring than the TANGO Database does not gets created – sandy560 Mar 14 '23 at 10:57
  • @danblack Could you just help me with after setting password if they are updating authentication_string as empty and plugin as empty why are they doing and in newer version how I can do this – sandy560 Mar 14 '23 at 11:14
  • a) check access with the new root password is correct `mariadb -u root -pmypassword` b) Follow step 9 carefully, you need to edit the password credentials into the script. The equivalents in [ALTER USER](https://mariadb.com/kb/en/alter-user/) won't help because mariadb doesn't things quite differently than the MySQL-4 that would have required such crude measures to set a password. – danblack Mar 14 '23 at 11:25
  • mypassword is working for mariadb, but that file doesn't gets generated might be because it is not able to connect to database can be one possibility, I will trouble shoot further and get back thanks for your time!!! – sandy560 Mar 14 '23 at 11:36
  • 1
    Just had a word with Team this method will is for old installation and will not work for new package they will be updating the document in some days Thanks!! – sandy560 Mar 15 '23 at 07:08

1 Answers1

1

You should never modify the system tables in the mysql schema. This is internal data and is likely to break things.

To secure your installation, you could use the mariadb-secure-installation script that comes with all MariaDB versions. This will set passwords for the root account as well as do other things to improve the security (e.g. remove anonymous users).

If you just want to prevent access with the root user, you can just drop it. To prevent all access with any of the root user accounts, you can use this:

DROP USER root@localhost;
DROP USER root@'%';
markusjm
  • 2,358
  • 1
  • 11
  • 23
  • Thanks for checking, Actually I'm using TANGO software which internally is dependant on mariadb below is the link which I'm referring in this link point 5 they have mentioned : https://www.tango-controls.org/community/forum/c/general/installation/installing-tango-934-on-ubuntu-lts-2004/ – sandy560 Mar 14 '23 at 09:50
  • The instructions there are definitely wrong and won't work on any modern MariaDB version. A better idea would be to run `mariadb-secure-installation` and set the root user password there. An even better idea might be to create a separate user for the program and use only the grants required to operate it. – markusjm Mar 14 '23 at 10:26
  • I'm checking on mariadb-secure-installation will let you know in sometime if it works or not – sandy560 Mar 14 '23 at 11:01
  • just checked with mariadb-secure-installation it allows me to change the root password but could you please help me with how can I perform `UPDATE mysql.user SET authentication_string = '' WHERE user = 'root'; UPDATE mysql.user SET plugin = '' WHERE user = 'root'; `using this – sandy560 Mar 14 '23 at 11:18
  • 1
    I don't think you need to do that, there's no good reason to execute those commands. – markusjm Mar 15 '23 at 06:15
  • 1
    Just had a word with Team this method will is for old installation and will not work for new package they will be updating the document in some days Thanks!! – sandy560 Mar 15 '23 at 07:08