linux下mysql-5.6忘记root密码,重置root密码详细过程
在linux平台下使用mysql过程中忘记了root密码,对于运维和DBA来讲都是一件头疼的事情,下面来讲解下怎么进行重置mysql数据库root 密码:
1、首先停止mysql服务进程:
1 service mysqld stop
然后编辑mysql的配置文件my.cnf
1 vim /etc/my.cnf
找到 [mysqld]这个模块:
在最后面添加一段代码
1 skip-grant-tables ##忽略mysql权限问题,直接登录
然后保存 :wq!退出
启动mysql服务:
1 service mysqld start
直接进入mysql数据库:
1 Starting MySQL. SUCCESS! 2 [root@web1 ~]# mysql3 Welcome to the MySQL monitor. Commands end with ; or \g.4 Your MySQL connection id is 15 Server version: 5.6.34 Source distribution6 7 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.8 9 Oracle is a registered trademark of Oracle Corporation and/or its 10 affiliates. Other names may be trademarks of their respective 11 owners. 12 13 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 14 15 mysql>
使用mysql表,然后进行修改mysql的root密码:
1 mysql> use mysql; ##使用mysql数据库2 Reading table information for completion of table and column names3 You can turn off this feature to get a quicker startup with -A4 5 Database changed6 mysql> update user set password=password("123456") where user="root";##更新密码7 Query OK, 4 rows affected (0.00 sec)8 Rows matched: 4 Changed: 4 Warnings: 09 10 mysql> flush privileges;##刷新权限 11 Query OK, 0 rows affected (0.00 sec)
1 [root@web1 ~]# ps -ef |grep mysql ##显示mysql现有的进程2 root 56407 1 0 17:50 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/web1.pid3 mysql 56533 56407 0 17:50 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/web1.err --pid-file=/data/mysql/web1.pid4 root 56560 1737 0 17:55 pts/0 00:00:00 grep mysql5 [root@web1 ~]# killall mysqld ##删除mysql现有进程6 [root@web1 ~]# ps -ef |grep mysql7 root 56566 1737 0 17:56 pts/0 00:00:00 grep mysql8 [root@web1 ~]# service mysqld start ##重新启动mysql服务9 Starting MySQL. SUCCESS! 10 [root@web1 ~]# mysql -uroot -p ##使用新密码登录 11 Enter password: 12 Welcome to the MySQL monitor. Commands end with ; or \g. 13 Your MySQL connection id is 1 14 Server version: 5.6.34 Source distribution 15 16 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. 17 18 Oracle is a registered trademark of Oracle Corporation and/or its 19 affiliates. Other names may be trademarks of their respective 20 owners. 21 22 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 23 24 mysql>
注意:先把mysql服务进程关闭,把添加过的跳过验证信息删除,要不然对数据库安全威胁太大,
转载于:https://www.cnblogs.com/pejsidney/p/9453205.html
linux下mysql-5.6忘记root密码,重置root密码详细过程相关推荐
- linux下mysql 8.0忘记密码后重置密码
设置免密码登陆 编辑mysql配置文件my.cnf 在最后添加skip-grant-tables 保存 重启mysql服务: service mysqld restart: 免密登录MySQL将旧密码 ...
- linux上mysql允许远程连接,linux下mysql允许远程连接
1. MySql安装教程 https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html 默认情况下mysq的 roo ...
- Linux下mysql ERROR 1045,Mysql无法执行批处理
Linux下mysql ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO) 每次启用mysql都出现这个 ...
- mysql在linux下备份还原,Linux下MySQL的备份与还原
Linux下MySQL的备份与还原 1. 备份 [root@localhost ~]# cd /var/lib/mysql (进入到MySQL库目录,根据自己的MySQL的安装情况调整目录) [roo ...
- linux下mysql的root密码忘记解决方
linux下mysql的root密码忘记解决方 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没 ...
- linux mysql解锁账号密码忘了怎么办,linux下mysql忘记密码怎么办
前言 今天在服务器安装mysql之后,登录发现密码错误,但是我没有设置密码呀,最后百度之后得知,mysql在5.7版本之后会自动创建一个初始密码. 报错如下: [root@mytestlnx02 ~] ...
- Linux下MySQL忘记密码
系统:CentOS6.6 64位 参考文档(截图请看原网址): Linux下MySQL忘记root密码怎么办_百度经验 http://jingyan.baidu.com/article/1709ad8 ...
- linux上mysql忘记密码,linux下mysql忘记密码解决方案
一.写随笔的原因:之前自己服务器上的mysql很久不用了,忘记了密码,所以写一下解决方案,以供以后参考 二.具体的内容: 1. 检查mysql服务是否启动,如果启动,关闭mysql服务 运行命令:ps ...
- Linux下mysql登录密码忘记解决
Linux下mysql登录密码忘记,需要修改配置文件,跳过密码验证,这样登录的时候,不同输入密码,直接回车即可登录,然后重置密码,设置完成后,退出mysql, 然后将配置文件中跳过密码的代码删除,保存 ...
- linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案
linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案 参考文章: (1)linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案 (2) ...
最新文章
- JS-封装js让一个div或者img的移动
- 在PS中如何进行图文互排,且层的使用……
- OS内核参数(SEM)在高负载的Oracle数据库中如何设置
- struts2面试整理
- 吃番薯叶有什么好处?
- phpExcel使用方法二
- BZOJ_2243 [SDOI2011]染色 【树链剖分+线段树】
- linux 播放器系统,Linux 中的十大开源视频播放器
- 收藏 | 基于深度学习的图像匹配技术一览
- vue渲染大量数据优化_Vue列表页渲染优化详解
- 99%的手机Root方法都在这里
- 阮一峰老师-Auth 2.0 的一个简单解释
- javax.crypto.AEADBadTagException: Tag mismatch 的解决办法
- 小米5s+刷+android+8.0,【小米5S标准版 解账户锁线刷包】MIUI V8.0.10.0 刷机 工具+驱动+教程!紫火提供版...
- Run-down Protection
- Python常见问题之单双引号使用错误
- 微信公众号的缩略图/封面图下载方法详细介绍
- pytest的url参数化调用和预期结果参数化
- 论文外文文献查找、翻译
- oss 服务端签名直传核心代码
热门文章
- 内嵌iframe_内嵌页面session超时,内嵌页面显示登录界面问题解决方案
- java web博客系统_JavaWeb之博客系统(五)
- 代理池proxypool新版使用教程
- linux第一次防火墙
- 移动开发者选项手机如何打开真机调试模式
- 高仿国美在线底部代码实现
- mysql+create+table+index_mysql------基础及常见SQL技巧
- adapter为null_软件设计精要之——适配器(Adapter)模式
- 基础练习 字母图形 c语言
- ftp server 可以实现你的电脑里的某个文件夹的共享