linux mysql下忘记root密码解决办法
1 修改MySQL的登录设置
# vi /etc/my.cnf
在[mysqld]的中加上一句:skip-grant-tables
2 重新启动mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
3 登录并修改MySQL的root密码
# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> USE mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User =
'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
4 将MySQL的登录设置修改回来
# vi /etc/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables删除
保存并且退出vi。
5 重新启动mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
Work for fun,Live
for love!
最新文章
- 黄聪:C#类似Jquery的html解析类HtmlAgilityPack基础类介绍及运用
- Linux下man手册使用
- 举例讲解Linux系统下Python调用系统Shell的方法
- SQL触发器、事物
- Calendar类测试
- ngrok反向代理
- eclipse编辑jsp快捷键保存时特别卡的解决方法
- 为rm命令增加回收站功能
- PHP中::、->;、self、$this操作符的区别
- HDU 4891 The Great Pan (模拟)
- C/C++语言中#的神奇作用:把宏参数字符串化/贴合宏参数
- WordPress 开放重定向漏洞
- Eclipse读取xml中文乱码问题解决
- python2.x 与 python3.x的不同
- linux压缩、解压缩和归档工具
- RNQOJ 21 FBI数
- Java SSM框架之MyBatis3(十)MyBatis批量插入数据(MySql)
- springboot-01 helloworld
- fastjson java类、字符串、jsonObject之前的转换
- U3D Transform用法