日期:2014-05-16  浏览次数:20792 次

mysql 更改root密码

mysql“Access denied for user 'root'@'localhost'”

首先以root 用户进入

?

server0:/usr/local/mysql/bin #service mysql stop

server0:/usr/local/mysql/bin # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

server0:/usr/local/mysql/bin # mysql -u root mysql

mysql>UPDATE user SET Password=PASSWORD('newpassword') where USER='root';

mysql> FLUSH PRIVILEGES;

mysql>\q

?

重启mysql

?

server0:/usr/local/mysql/bin #service mysql start

server0:/usr/local/mysql/bin #mysql -uroot -p

server0:/usr/local/mysql/bin #Enter password:

mysql>