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

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.Start the mysql server instance or daemon with the --skip-grant-tables option. (security setting)

$ mysqld --skip-grant-tables
2.Then Execute these statements.

$ 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

你可能感兴趣的:(mysql,Access,password,denied)