-
service mysqld stop
-
vi /etc/my.cnf
-
在[mysqld]片段中开始新增skip-grant-tables,保存退出vi
-
service mysqld start
-
mysql -u root mysql
,进入mysql -
mysql>use mysql;
-
update mysql.user set authentication_string=password('123456') where user='root';
或者
mysql>update user set password=PASSWORD(’111111’) where user=’root’;
-
mysql>flush privileges;
-
mysql>quit;
-
vi /etc/my.cnf,删除skip-grant-tables,保存退出vi
-
service mysqld start
-
mysql -u root -p
如果碰到
You must reset your password using ALTER USER statement before executing this statement.
MySQL版本5.7.6版本(以前)用户可以使用如下命令:
mysql>SET PASSWORD = PASSWORD('密码');
MySQL版本5.7.6版本(开始后)的用户可以使用如下命令:
mysql> ALTER USER USER() IDENTIFIED BY '密码';