步骤一:
登录mysql,输入mysql -uroot -p并回车,此时登录成功。
步骤二:
检查mysql表是否可以看见,输入show databases;并回车。
步骤三:
查看root用户和其他用户之前的密码:
select host, user, password from mysql.user;
步骤四:
修改root用户密码:
Grant all privileges on *.* to 'root’@‘*' identified by '123456!' with grant option;
Grant all privileges on *.* to 'root’@'localhost' identified by '123456!' with grant option;
Grant all privileges on *.* to 'root’@‘127.0.0.1' identified by '123456!' with grant option;
步骤五:
新增michal并设置dink库的密码:
Grant all privileges on *dink* to ‘michal’@‘*' identified by '123456!' with grant option;
Grant all privileges on *dink* to ‘michal’@'localhost' identified by '123456!' with grant option;
Grant all privileges on *dink* to ‘michal’@‘127.0.0.1' identified by '123456!' with grant option;
步骤六:
执行刷新操作:
flush privileges;
步骤七:
查看root用户和其他用户之前的密码是否已经修改
select host, user, password from mysql.user;
步骤八:
退出命令行
quit
步骤十三:
重启mysql服务:
service mysqld restart
步骤十四:
执行命令,输入密码看是否能正常访问
mysql -uroot -p
mysql -umichal -p
网友评论