1.
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables #加上这句
2.
# /etc/init.d/mysql restart
3.
# /usr/bin/mysql
mysql> USE mysql ;
mysql> UPDATE user SET Password = password('new-password') WHERE User = 'root' ;
mysql> flush privileges ;
mysql> quit
4.
# vi /etc/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables注释或删除
5.
# /etc/init.d/mysql restart
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables #加上这句
2.
# /etc/init.d/mysql restart
3.
# /usr/bin/mysql
mysql> USE mysql ;
mysql> UPDATE user SET Password = password('new-password') WHERE User = 'root' ;
mysql> flush privileges ;
mysql> quit
4.
# vi /etc/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables注释或删除
5.
# /etc/init.d/mysql restart