版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/van_brilliant/article/details/80022256
在自己的电脑上装了半天mysql之后没装成功,最后在阿里云的服务器上装上去了。首先建议在安装mysql之前创建一个mysql用户,然后切换到这个用户下安装,这样会少很多权限问题。具体安装过程网上有很多,我是用glibc方式装的。但是又忘记记下初始密码了。记录一下找回密码过程中出现的一系列问题。
- 在my.cnf中加入skip-grant-tables,以跳过密码的方式登录mysql。
vim /etc/my.cnf
- 重新启动并登录mysql,修改密码
service mysql restart
mysql -uroot
use mysql;
update mysql.user set authentication_string=password('123456') where user='root';
- 删除my.cnf中的免密码登录配置,再次重启mysql然后用刚刚设置的密码登录
service mysql restart
mysql -uroot -p123456
- 此时出现提示:Your password has expired. To log in you must change it using a client that supports expired passwords
mysql安装目录/bin/mysqladmin -uroot -p password
然后输入刚刚设置的密码即可。重新登录mysql,问题解决。