1.{ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)}
找到mysql的配置文件。这里我用的是oneinstack一键安装,文件目录为/etc/my.cnf.
编辑my.cnf,找到[mysqld] 这一项,然后在这一项下面添加skip-grant-tables。
示例:
[mysqld] skip-grant-tables port = 3306 socket = /tmp/mysql.sock
保存配置文件。然后重启mysqld服务。
#无需密码直接回车登录 /usr/local/mysql/bin/mysql -uroot -p #更改密码为root set password for 'root'@'localhost' = password('root'); #可能会出现这种提示 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement #出现上述提示,执行如下命令,再更改密码 flush privileges;
更改完,密码配置文件删除skip-grant-tables,然后重启mysqld,即可正常登录。
0 条评论