有时侯我们可能会忘记数据库的登陆密码,本节将讲述如何修改mysql的登陆密码!
1. 跳过授权表并重启mysql
vim /etc/my.cnf
skip-grant-tables #添加参数
/etc/init.d/mysqld restart #进行重启
2. 进入并清空root的密码
mysql -p
> updata mysql.user set authentication_string='' where user='root';
> exit
vim /etc/my.cnf
#skip-grant-tables 注释掉这行参数
/etc/init.d/mysqld restart #重启
3. 重新设置密码
mysql -p
> alter user root@localhost identified by 'westos';
> flush privileges;