在centos6.4系统上使用yum方式安装mysql5.6后,使用/usr/bin/mysql_install_db --user=mysql 设置授权表后。
登录mysql时候 ,爆出如下错误:
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ’root’@’localhost’ (using password: NO)
想修改密码,也爆出错误:
# mysqladmin -uroot -p password ’newpassword’
Enter password:
mysqladmin: connect to server at ’localhost’ failed
error: ’Access denied for user ’root’@’localhost’ (using password: YES)’
没办法,只能手动停止mysql,重置密码。官方教程见 http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html
首先关闭mysql,
# /etc/init.d/mysql stop
使用user=mysql 重启,不带此参数,会使用root启动,导致某些文件操作没有权限。启动会失败。同时忽略 授权表,如下
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
启动后,mysql -u root mysql 登录mysql。
修改成功,正常登录!