第一步:修改配置文件免密码登录mysql

1、进入文件:vi /etc/my.cnf

2、按i键表示可以编辑;添加skip-grant-tables;按esc键,输入:wq保存退出

3、重启mysql:sudo service mysqld restart

第二步免密码登录mysql

1、登录:mysql -u root -p

2、提示输入密码按回车进入

3、进入数据库,输入:use mysql;

4、修改密码

update user set authentication_string=” where user=’root’;

FLUSH PRIVILEGES;

alter user ‘root’@’localhost’ identified by ‘你的密码’;

FLUSH PRIVILEGES;

成功修改

5、编辑my.ini 注释掉skip-grant-tables,重启mysql。

By xbingo

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注