一、错误消息:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)解决:
1、打开mysql配置文件 /etc/mysql/my.cnf ,添加一行“skip-grant-tables"配置,作用是在mysql启动时不启动授权表以便忘记密码后使用。2、重启mysql服务,service mysql restart3、命令行输入“mysql -uroot -p”(不输入密码),回车进入数据库。4、执行 use mysql;”使用mysql数据库。5、执行 update user set password=PASSWORD("newpassword") where Host='localhost' and user='root';”(修改root的密码)6、再打开 /etc/mysql/my.cnf ,删除 skip-grant-tables配置, 保存并关闭文件。7、 重启mysql服务8、在命令行中输入“mysql -uroot -p newpassword”,问题搞定!
二、解决修改数据库帐号密码、或host时,无效问题
1.使用ssh直接连接到数据库,不要使用工具连接
2.执行flush privileges 刷新权限
三、解决1130,远程访问权限问题
grant all privileges on *.* to 'root'@'%' identified by 'rootpasswd' with grant option;
来源:oschina
链接:https://my.oschina.net/u/2270392/blog/496256