Linux下重置密码的操作与Windows下类似。
[root@www ~]# /etc/init.d/mysql stop
[root@www ~]# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &
[root@www ~]# mysql -u root -p
mysql> use mysql; mysql> update user set password=password("123456") where user="root"; mysql> flush privileges;
[root@www ~]# /etc/init.d/mysql start 注意了,MySQL5.7之后,重置root密码SQL(感谢刘韦声回复):
update mysql.user set authentication_string=password('123456') where user='root';
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON myapp.* TO 'username'@'localhost';
FLUSH PRIVILEGES