CentOS 7.7解决yum方式安装的MySQL 5.7 root用户密码丢失问题
时间:2020-02-25来源:电脑系统城作者:电脑系统城
1、没有输入或输入错误的root用户密码,无法进入数据库:
# mysql -uroot -p
- 没有输入root用户密码,直接回车:
- 输入错误的root用户密码:
- 强制结束MySQL进程:
# yum -y install psmisc
# killall mysqld
# pkill mysqld
# ps -ef | grep mysql
# ss -tunlp | grep 3306
- 使用mysqld命令,增加--skip-grant-tables参数,跳过权限表,启动数据库:
# mysqld --defaults-file=/etc/my.cnf --user=mysql --skip-grant-tables &# ps -ef | grep mysql
# ss -tunlp | grep 3306
- 使用mysql命令直接进入数据库,为root用户设置新的密码并刷新权限:
# mysqlmysql> use mysql;
mysql> update user set authentication_string=password('
root@1234') where user='root';
mysql> flush privileges;
- 重启数据库:
# killall mysqld
# pkill mysqld
# ps -ef | grep mysql
# ss -tunlp | grep 3306
# systemctl start mysqld
- 输入root用户新设置的密码root@1234,进入数据库:
# mysql -uroot -p
相关信息
-
tomcat 启动时卡住问题排查及解决方法
正常项目无法访问(Linux 服务器),启动tomcat时卡在下图位置,项目无法启动。1、先检查tomcat日志、项目日志没有报错信息,且没再产生新的日志信息。2、jdk、tomcat 、 jvm 配置,服...
2023-03-15
-