欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Access denied for user 'root'@'localhost' (using password: Yes)或者No的解决

程序员文章站 2022-05-19 21:46:18
...
这个提示主要是因为root登录需要密码,而密码如果不正确的提示

主要通过修改mysql的配置来跳过权限限制,来实现登录

而可以通过修改my.cnf/my.ini增加--skip-grant-tables来跳过,也可以通过mysql启动增加参数来实现,不过两者都需要重新启动mysql

http://*.com/questions/19533441/access-denied-for-user-rootlocalhost-using-password-yes-after-password-r


Mac下的mysql目录为/usr/local/mysql/bin/,有时候会用到,如果配置环境变量了,可以直接使用下面的每一步操作

Follow steps below

1.启动mysqld的实例通过--skip-grant-tables参数,启动mysql,就可以跳过授权方式登录,修改完后别忘了再重启mysql
$ mysqld start --skip-grant-tables


$ mysql -u root mysql
$mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root';
$mysql> FLUSH PRIVILEGES;
3.Finally, restart the instance/daemon without the --skip-grant-tables option.

$ /etc/init.d/mysql restart
4.You should be able to connect with your new password.

$ mysql -u root -p
Enter password: my_password

NEW UPDATE

Mysql Unable to lock ibdata1 error fix

sudo mv /usr/local/mysql/data/ibdata1 /usr/local/mysql/data/ibdata1.bak
sudo mv /usr/local/mysql/data/ib_logfile0 /usr/local/mysql/data/ib_logfile0.bak
sudo mv /usr/local/mysql/data/ib_logfile1 /usr/local/mysql/data/ib_logfile1.bak
sudo cp -a /usr/local/mysql/data/ibdata1.bak /usr/local/mysql/data/ibdata1
sudo cp -a /usr/local/mysql/data/ib_logfile0.bak /usr/local/mysql/data/ib_logfile0
sudo cp -a /usr/local/mysql/data/ib_logfile1.bak /usr/local/mysql/data/ib_logfile1
sudo /etc/init.d/mysql restart

上一篇: 困死了

下一篇: 新手驾车