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'; #多执行一遍