1 頁 (共 1 頁)

16.04 Normal User can't use mysql root account

發表於 : 2017-06-03 16:00:13
yehlu
https://stackoverflow.com/questions/392 ... tlocalhost

代碼: 選擇全部

$ sudo mysql -u root

[mysql] use mysql;
[mysql] update user set plugin='' where User='root';
[mysql] flush privileges;
[mysql] \q 



yehlu@x4-640:/var/www/html/carstatus$ mysql carstatus -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

root@x4-640:/etc/mysql/mariadb.conf.d# mysql mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.0.29-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+------+-----------+-------------+
| User | Host | plugin |
+------+-----------+-------------+
| root | localhost | unix_socket |
+------+-----------+-------------+
1 row in set (0.00 sec)

MariaDB [mysql]> update user set plugin='' where User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+------+-----------+--------+
| User | Host | plugin |
+------+-----------+--------+
| root | localhost | |
+------+-----------+--------+
1 row in set (0.00 sec)