使用宝塔安装mysql后,忘记了初始密码。在linux下如何修改mysql的密码呢?
我的服务器环境:
CentOS Linux 7.2.1511 宝塔7.0.3 mysql 5.7.26(版本不一样,操作可能不一样)
步骤:
- 在宝塔中修改mysql配置文件,mysqld区段中添加 skip-grant-tables
宝塔mysql配置 -
重启mysql
在xshell中输入:service mysqld restart
3. 重新进入 mysql,此时进入是不需要输入密码的
![开启mysql](https://img-blog.csdnimg.cn/20200108202249958.png)
4.修改密码(操作mysql中的user表)
![操作user表](https://img-blog.csdnimg.cn/20200108202538844.png)
use mysql;
update user set authentication_string = password('your password') where user ='root';
注意:我的是5.7版本的,所以用的 authentication_string,低版本使用 password = password('your password')
5.将配置文件中添加的行删除 skip-grant-tables