MySQL 改 root 密碼

2013-08-31 16:22

SUSE 10.3上裝完MYSQL
啟動時都正常,但要設定密碼時出現錯誤

SU103:/ # /etc/init.d/mysql start
Starting service MySQL                                               done
SU103:/ # mysqladmin -u root password 'xxxxxxxx'
mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user
'root'@'localhost' (using password: NO)'

處理方式如下

 

SU103:~ # service mysql stop
Shutting down service MySQL                                          done
SU103:~ # clear
SU103:~ # mysqld_safe --skip-grant-tables &
[1] 19984
SU103:~ # nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql

SU103:~ # mysql -u root mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45 SUSE MySQL RPM

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> UPDATE user SET Password=PASSWORD('xxxxxx') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
SU103:~ # /etc/init.d/mysql restart
Restarting service MySQL
Shutting down service MySQL                                          done
Starting service MySQL                                               done
SU103:~ # mysql -u root -p
Enter password:xxxxxx
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 SUSE MySQL RPM

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>