天天看点

Mysql常见错误处理(持续更新)

  • ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement​
  • mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'

上面两个问题,第一个是无密码登录状态不能执行一些命令和SQL语句.

第二个是密码错误不能连接.需要先切换到无密码登录状态. 在my.ini添加skip-grant-tables.重启mysql服务.

下面的步骤都是修改密码

  1. 在skip-grant-tables状态下修改root密码为空

MySQL 5.7.6+版本以上,在UPDATE语句中使用authentication_string列代替password列.

​use mysql​

​update user ​

​set authentication_string = '' ​

​WHERE user = 'dbadmin' AND host = 'localhost';​

​FLUSH PRIVILEGES;​

  1. 编辑my.ini文件删除skip-grant-tables,重启mysql服务.

vi /etc/my.ini

​service mysqld start/stop/restart

或:systemctl mysqld restart

mysql -uroot -p

再次执行SQL命令就可以

继续阅读