xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

MySQL 8.x Error All In One

MySQL 8.x Error All In One

login error

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

image

问题排查

https://www.cnblogs.com/zhongyehai/p/10695334.html

solutions

  1. 密码错误 ✅

Sql@2022 => sql@2022

密码长度是最短八个字符的组合,必须同时包含英文单词的字母数字和其他特殊字符,但是没有强调字母的大小写

  1. 修改密码
$ sudo grep 'temporary password' /var/log/mysqld.log

# Change the root password as soon as possible by logging in with the generated temporary password and set a custom password for the superuser account:

$ mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Sql@2022'; 

https://stackoverflow.com/questions/21944936/error-1045-28000-access-denied-for-user-rootlocalhost-using-password-y/42967789#42967789

登录 MySQL

mysql -h 主机名 -u 用户名 -p
参数说明:

-h : 指定客户端所要登录的 MySQL 主机名, 登录本机(localhost 或 127.0.0.1)该参数可以省略;
-u : 登录的用户名;
-p : 告诉服务器将会使用一个密码来登录, 如果所要登录的用户名密码为空, 可以忽略此选项。

https://www.runoob.com/mysql/mysql-install.html#:~:text=即可启动 mysql。-,登录 MySQL,-当 MySQL 服务

MySQL 8.x 远程登录不了问题及解决方案

# 修改 ❓  'root'@'%'  不存在,所以修改不了
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'sql@2022';
#  ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%' ❌

# 授权 ❓  'root'@'%'  不存在,所以授权不了
mysql> GRANT ALL ON *.* TO 'root'@'%';
# ERROR 1410 (42000): You are not allowed to create a user with GRANT ❌

# 更新 ✅ host 的值可以更新
mysql> update user set host = '%' where user = 'root';

# 刷新
mysql> flush privileges;

image

refs

https://github.com/xgqfrms/mysql/issues/7#issuecomment-1278575049

https://www.jianshu.com/p/435307de1c29



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-10-14 20:52  xgqfrms  阅读(16)  评论(2编辑  收藏  举报