才装完的mysql,转眼密码就忘记了,找了一圈的修改密码方法,做下记录!

  1. 编辑mysql配置文件。
[root@localhost ~]# vi /etc/my.cnf
  1. [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
  1. 保存配置文件后,重启mysql服务。
[root@localhost ~]# systemctl restart mysqld.service
  1. 使用mysql命令登录mysql数据库。
[root@localhost ~]# mysql
  1. 使用下面语句修改root密码,注意和之前版本的mysql语句不太一样。
mysql>update mysql.user set authentication_string=password('新密码') where user='root' ;
mysql>flush privileges ;
mysql>quit
  1. 编辑mysql配置文件,将之前添加的 skip-grant-tables去掉。
  2. 重启mysql服务。
[root@localhost ~]# systemctl restart mysqld.service

最新文章

  1. Android混淆打包
  2. Displaying Bitmaps Efficiently 显示图片相关
  3. 使用SharpSSH连接服务器报Algorithm negotiation fail解决办法
  4. SystemTap知识(一)
  5. Qt设置系统时间(使用SetSystemTime API函数)
  6. SyntaxError: Non-ASCII character '\xe7' in file解决方法
  7. oracle11g空表不能导出记录
  8. JavaScript中事件绑定的方法总结
  9. 【技术贴】解决xp下Microsoft.SqlServer.Management.PSProvider.dll
  10. WCF 接收我服务的 HTTP 响应时发生错误
  11. 利用内存结构及多线程优化多图片下载(IOS篇)
  12. EC读书笔记系列之13:条款25 考虑写出一个不抛异常的swap函数
  13. 14.8.2 Verifying File Format Compatibility 校验文件格式兼容性:
  14. Android Bitmap OutOfMemory 解决的方法
  15. java中的静态代理和动态代理,入门整理
  16. Python sys和shutil模块
  17. 8. Security-oriented operating systems (面向安全的操作系统 5个)
  18. Flume的监控参数
  19. matplotlib 画图
  20. IDEA分享项目到GitHub出现Could not read from remote repository

热门文章

  1. Error: Finish can only be called once
  2. 移植QT5.6到嵌入式开发板(史上最详细的QT移植教程)
  3. [C#.NET] X509 數位電子簽章
  4. Win10系统开启Linux Bash命令行
  5. beyond compare 比较Xls文件时只显示有差异的列
  6. [Grunt] Concatenating Your Javascript with grunt-contrib-concat
  7. 魔术布局效果-使用本地JSON数据提供数据服务
  8. RaceWeb介绍(7):由500强公司数据高速生成百度地图——生成坐标字段及坐标数据
  9. asp与aspx有什么区别
  10. 委托批量处理Excel