新入职一家公司,没有centos7.x系统mysql数据库密码怎么办?
1、root用户登陆centos7.x系统
2、启动mysql服务
/etc/init.d/mysqld start
service mysqld start
systemctl start mysqld.service
3、查看mysql端口状态
lsof -i :3306 netstat -lntup |grep 3306 ss -antp |grep 3306
4、修改数据库配置文件,在[mysqld]中添加skip-grant-tables参数,并重启mysql服务
vim /etc/my.cnf [mysqld] skip-grant-tables
systemctl restart mysqld.service
5、使用root账户进入数据库
mysql -uroot
6、使用mysql数据库更新root密码
update user set password = PASSWORD(‘newpassword’) where user = ‘root‘; flush privileges;
7、把刚才修改/etc/my.cnf参数注释掉,重启mysql,并使用密码登陆数据库
mysql -uroot -p‘newpassword‘
原文:https://www.cnblogs.com/luowenbin/p/11119662.html