用root登入,出現Access denied for user 'root'@'localhost'
解決方式:
1.進入ssh
sudo su -
2.停止mysql
> cd /usr/local/etc/rc.d/
> ./mysql-server stop
3啟動mysql
> mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
4.進入mysql
> mysql -u root mysql
5.更新 root 密碼
mysql> update user set password=PASSWORD('XXX') where user='root';
mysql> flush privileges;
mysql> exit;
6.重啟mysql
/usr/local/bin/mysqld_safe &
或
cd /usr/local/etc/rc.d/
./mysql-server restart
7.測試密碼
mysql -uroot -p
Enter password:
沒有留言:
張貼留言