Quesions about MySQL/Mariadb modify password

StartTime: 2017-12-09,ModifyTime:2017-12-09

Modify root’s password

MariaDB [(none)]> sudo mysqld_safe --skip-grant-tables &

New terminal:

MariaDB [(none)]> mysql -u root
MariaDB [(none)]> UPDATE user SET password=PASSWORD("your_password") WHERE user='root' AND Host = 'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;

Check result:

MariaDB [(none)]> select user, host, password, plugin, authentication_string from mysql.user;

Modify the login method

If you try the method IDENTIFIED VIA unix_socket should be IDENTIFIED BY PASSWORD.

MariaDB [(none)]> SHOW GRANTS FOR 'root'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket USING '*A4B6157319038724E3560894F7F932C8886EBFCF' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION

The column of plugin,authentication_string should be null.

MariaDB [(none)]> select user, host, password, plugin, authentication_string from mysql.user;

References:

Modify root’s password
Modify root’s password
Add mysql user

您如果觉得有用,觉得写得还不错,可以一元赞赏作者。
   
微信捐赠图片
   
支付宝捐赠图片