centos命令行安装mysql随机密码查看方法(遇到问题及其解决办法)

mysql初次命令行安装登录时报错:

未输入密码:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

或者

输入密码错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

mysql初次登录报错(命令行安装会生成随机密码)
mysql安装成功后创建的超级用户'root'@'localhost'的密码会被存储在/var/log/mysqld.log
查看方法:

grep 'temporary password' /var/log/mysqld.log

 复制这个密码,登录mysql -u root -p ,即可登录成功。

登录成功后,执行不了任何操作,报错,要求修改初始密码:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

命令行修改root密码:

mysql命令:alter user 'root'@'localhost' identified by 'wxy123456';

此时此刻,在服务器上就可以使用自己的密码成功使用mysql了,那么远程登陆mysql怎么办?

Navicat连接MySQL Server8.0版本时出现Client does not support authentication protocol requested  by server;解决如下:

允许root用户远程登陆命令如下:

1、use mysql;

2、alter user 'root'@'%' identified with mysql_native_password by 'wxy123456';

3、flush privileges;

 

posted @ 2019-04-25 15:58  王醒燕  阅读(136)  评论(0编辑  收藏