一、重建本地用户:
#vi /etc/my.cnf
[mysqld]
skip-grant-tables
# service mysql restart
Shutting down MySQL.. done
Starting MySQL.
# mysql -uroot -p
Enter password:
mysql> insert into mysql.user (host, user, password,ssl_cipher,x509_issuer,x509_subject) values (‘localhost‘, ‘root‘, password(‘root‘),‘‘,‘‘,‘‘);
Query OK, 1 row affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to ‘root‘@‘localhost‘ identified by ‘root‘ with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql>
vi /etc/my.cnf
[mysqld]
#skip-grant-tables
# service mysql restart
Shutting down MySQL..
Starting MySQL.
三、通过本地用户重建远程用户:
mysql -uroot -proot
mysql> select user,host from mysql.user;
+----------+-----------+
| user | host |
+----------+-----------+
| root | localhost |
+----------+-----------+
5 rows in set (0.00 sec)
mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘root‘ with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user;
+----------+-----------+
| user | host |
+----------+-----------+
| root | % |
| root | localhost |
+----------+-----------+