重置mysql密码

1.停止mysql服务器运行,-> service mysql stop

2.进入 mysql 安装目录 /usr/bin/

-> mysqld --skip-grant-tables 

3. 重新打开远程连接,进入mysql 重置密码

mysql> UPDATE mysql.user SET Password=PASSWORD('lianruihong')  WHERE User='root';
mysql> FLUSH PRIVILEGES;

连接mysql的时候发生这个错误:

ERROR 1130: Host [ip] is not allowed to connect to this MySQL server

mysql>update user set host = '%' where user = 'root';

原文地址:https://www.cnblogs.com/lianruihong/p/7656015.html