码迷,mamicode.com
首页 > 数据库 > 详细

Linux重置MySQL密码

时间:2020-03-18 18:59:01      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:ora   word   padding   重置   nec   linu   acl   set   Owner   

1.停止mysql程序

1
2
[root@H0f ~]# service mysqld stop
Stopping mysqld:                                           [  OK  ]

 2.打开mysql配置文件

1
[root@H0f ~]# vim /etc/my.cnf搜索mysqlld    /mysqld[mysqld]#下一行添加skip-grant-tables  #忽略MySQL权限问题,直接登录

 3.开启MySQL服务

1
[root@H0f ~]# service mysqld start

 4.无密码直接进入mysql

技术图片
1
2
3
4
5
6
7
8
9
10
11
12
[root@H0f ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73-log Source distribution
 
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
技术图片

5.使用mysql表,进行修改密码

1
2
3
4
5
<strong>mysql> use mysql</strong>
Database changed
<strong>mysql> update user set password=password("123") where user="root";#密码修改为123</strong>
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

 6.刷新权限

1
2
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 7.杀死所有mysqld进程

1
2
3
[root@H0f ~]# killall mysqld
[root@H0f ~]# ps -ef|grep mysqld
root      53342  45198  0 20:57 pts/6    00:00:00 grep mysqld

 8.开启mysqld服务

1
2
[root@H0f ~]# service mysqld start
Starting mysqld:                                           [  OK  ]

 9.测试进入mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@H0f ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73-log Source distribution
 
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
 
mysql>

 

Linux重置MySQL密码

标签:ora   word   padding   重置   nec   linu   acl   set   Owner   

原文地址:https://www.cnblogs.com/qiaosipo/p/12519112.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!