今天我们主要是讲一下关于linux忘记mysql密码处理方法,下面提供了5种linux忘记mysql密码找回方法哦。
方法一(先进入root权限):

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root
mysql> update user set password=password("newpassword") where user='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
enter password: <输入新设的密码newpassword>
mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
enter password: <输入[client]节的密码>
mysql> update user set password=password("newpassword")  where user=root;
mysql> flush privileges;
mysql> quit
# mysql -uroot -p
enter password: <输入新设的密码newpassword>
mysql>
方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!!
# mysql -uroot -p
enter password: <输入/etc/mysql/debian.cnf文件中[client]节提供的密码>
方法四:
方法如下: 1, 关闭mysql服务 /etc/init.d/mysqld stop 2,使用 –skip-grant-tables选项启动mysql服务,可以修 改/etc/inin.d/mysqld脚本启动位置增加此选项, vi /etc/init.d/mysqld
方法如下:
1, 关闭mysql服务
/etc/init.d/mysqld stop
2,使用 –skip-grant-tables选项启动mysql服务,可以修 改/etc/inin.d/mysqld脚本启动位置增加此选项,
vi /etc/init.d/mysqld
在下面运行启动的语句里增加--skip-grant-tables
/usr/bin/mysqld_safe --skip-grant-tables --datadir="$datadir" --socket="$socketfile"
--log-error="$errlogfile" --pid-file="$mypidfile"
加入--skip-grant-tables的意思是启动mysql服务的时候跳 过权限表认证。启动后,连接到mysql的root不需要口令
3,重新启动mysql服务
/etc/init.d/mysqld start
4. 修改root用户的密码;
mysql> update mysql.user set password=password("123456")where user=root;
mysql> flush privileges;
mysql> quit
5. 重新启动mysql,就可以使用 新密码登录了。
mysql
mysql -u root –p
输入密码:123456
6,关闭mysql服务
/etc/init.d/mysqld stop
7, 重新修改第2步修改的/etc/init.d/mysqld,使其保持原来不变,也就是取消--skip-grant-tables语句
8,重新 启动mysql服务
/etc/init.d/mysqld start

后记:

新安装的MySQL是有密码的,但是其实自动存储在了某个文件夹中,我安装的是MySQL-server-5.6.35-1.el6.x86_64.rpm,rpm安装方式,MySQL的root密码;默认的密码存在:/root/.mysql_secret 这个文件夹中.///但是我就是打不开.SO..,就当忘记密码,如何找回MySQL的初始的root密码.找到的方法都是可行的,但是唯一不好的是可能我这个版本的设置newpasswd的时候新的密码需要用双引号,而原博主没有.所以转过来备自己使用.

下附原地址:

https://www.2cto.com/os/201104/86881.html

最新文章

  1. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(9)-MVC与EasyUI结合增删改查
  2. 备忘:mybatis 3的使用记录
  3. Ubuntu离线更新flashplugin
  4. [MacOSX]
  5. 使用 TC 对LInux中vpn 上传下载进行限速(转)
  6. jQuery_Ajax_Json 异步接收PHP端传来的json数据
  7. alfresco 5.0 document
  8. JAVA的StringBuffer类(转载整理)____非常重要的一个类,线程安全,不用每次创建一个对象,以及和String的区别
  9. Android进程间通信(IPC)机制Binder简要介绍和学习计划
  10. SVN:One or more files are in a conflicted state
  11. 最近新版本的pangolin出现了点问题,我把可用的旧版本上传到了github
  12. 【WPF】DispatcherFrame 是个啥玩意儿
  13. win10 uwp 自定义控件 SplitViewItem
  14. python/零起点(一、字典)
  15. Spring Security(三十五):Part III. Testing
  16. 第四十篇-private,public,protected的区别
  17. GUI相应鼠标事件
  18. Linux内核分析 笔记四 系统调用的三个层次 ——by王玥
  19. Linux 增量系统备份和部分还原策略
  20. 关于在浏览器中测试cordova plugin的注意事项。

热门文章

  1. 30分钟了解如何使用Kafka
  2. 最大容积 Container With Most Water
  3. scRNA-seq单细胞测序数据分析工具汇总
  4. .NET中使用Rabbit MQ
  5. 『PyTorch』第十二弹_nn.Module和nn.functional
  6. 转化为json方式函数
  7. Leetcode 114
  8. Leetcode 74
  9. en_e out1
  10. vm options设置