centos7下忘记mysql密码
程序员文章站
2022-03-09 11:48:49
...
才装完的mysql,转眼密码就忘记了,找了一圈的修改密码方法,做下记录!
1.编辑mysql配置文件。
[aaa@qq.com ~]# vi /etc/my.cnf
2.在[mysqld]配置节下新增skip-grant-tables。
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
"/etc/my.cnf" 29L, 979C written
3.保存配置文件后,重启mysql服务。
[aaa@qq.com ~]# systemctl restart mysqld.service
4.使用mysql命令登录mysql数据库。
[aaa@qq.com ~]# mysql
5.使用下面语句修改root密码,注意和之前版本的mysql语句不太一样。
mysql>update mysql.user set authentication_string=password('新密码') where user='root' ;
mysql>flush privileges ;
mysql>quit
6.编辑mysql配置文件,将之前添加的skip-grant-tables去掉。
7.重启mysql服务。
[aaa@qq.com ~]# systemctl restart mysqld.service
转载:https://www.cnblogs.com/yanziwen/p/9215264.html
所有巧合的是要么是上天注定要么是一个人偷偷的在努力。
个人微信公众号,专注于学习资源、笔记分享,欢迎关注。我们一起成长,一起学习。一直纯真着,善良着,温情地热爱生活,,如果觉得有点用的话,请不要吝啬你手中点赞的权力,谢谢我亲爱的读者朋友。
-Fear not that the life shall come to an end, but rather fear that it shall never have a beginning.——J.H. Newman
「不要害怕你的生活将要结束,应该担心你的生活永远不会真正开始。——纽曼」
上一篇: Linux 目录介绍以及安装JDK 详解
推荐阅读
-
mysql 忘记密码的解决方法(linux和windows小结)
-
Windows 8.1下MySQL5.7 忘记root 密码的解决方法
-
linux(Centos7)下安装mysql8.0.18的教程图解
-
Linux下Centos7安装Mysql5.7.19的详细教程
-
虚拟机Linux系统忘记密码的情况下,修改root或其他用户密码
-
Mysql的Root密码忘记,查看或修改的解决方法(图文介绍)
-
CentOS7下mysql 8.0.16 安装配置方法图文教程
-
MySQL忘记密码恢复密码的实现方法
-
CentOS7 64位下MySQL5.7安装与配置
-
CentOS7下 MySQL定时自动备份的实现方法