`
LiYunpeng
  • 浏览: 954478 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

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

阅读更多
这个提示主要是因为root登录需要密码,而密码如果不正确的提示

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

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

http://stackoverflow.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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics