Linux登录MySQL过程中遇到的诸多问题集锦

本文详细介绍了Linux环境下MySQL登录时遇到的Access denied错误,包括密码验证问题、SQL语法错误,以及远程访问权限设置的步骤。提供了解决方案和密码创建最佳实践,助你快速定位并解决这些问题。
摘要由CSDN通过智能技术生成

Linux登录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)

解决:

[root@localhost ~]#grep 'temporary password' /var/log/mysqld.log

问题二:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(“123456”) where user=“root”

或者

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘password(‘123456’)’ at line 1

解决:

mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY '你的新密码';
#满足密码新建要求8位,大写,小写,数字,特殊符号
例如:(临时创建,然后进行修改)
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'Zz@123456';

修改密码创建要求:

mysql>show variables like 'validate_password%';
mysql>set global validate_password.length=6;
mysql>set global validate_password.policy=0;
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

问题三:MySQL数据库远程访问权限打开问题

grant all privileges on . to ‘root’@’%’ identified by ‘123456’;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘identified by ‘123456’’ at line 1

解决:

mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select  User,authentication_string,Host from user;
mysql>ALTER USER 'root'@'%' IDENTIFIED BY '123456'; #多执行一遍
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

流苏树

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值