程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQL修正root賬號暗碼的辦法

MySQL修正root賬號暗碼的辦法

編輯:MySQL綜合教程

MySQL修正root賬號暗碼的辦法。本站提示廣大學習愛好者:(MySQL修正root賬號暗碼的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是MySQL修正root賬號暗碼的辦法正文


MySQL數據庫中若何修正root用戶的暗碼呢?上面總結了修正root用戶暗碼的一些辦法

1: 應用set password語句修正

mysql> select user();
+----------------+
| user()  |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.08 sec)
 
mysql> set password=password('123456');
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> exit

2: 更新mysql數據庫的user表

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('QwE123') where user='root';
Query OK, 4 rows affected (0.03 sec)
Rows matched: 4 Changed: 4 Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit

3:應用mysqladmin敕令修正

敕令普通為 mysqladmin -u root -p'oldpassword' password newpass 以下所示:

[root@DB-Server ~]# mysqladmin -u root -p'123456' password 'Qwe123'
Warning: Using a password on the command line interface can be insecure.

驗證root暗碼修正能否勝利

[root@DB-Server ~]# mysqladmin -u root -p'123456' password 'Qwe123'
Warning: Using a password on the command line interface can be insecure.


 

下面都是在曉得root暗碼的情形下修正root暗碼,假如忘卻了root暗碼,若何修正root的暗碼呢?

1:起首停失落MySQL辦事

[root@DB-Server ~]# service mysql stop
Shutting down MySQL..[ OK ]
[root@DB-Server ~]# 


[root@DB-Server ~]# /etc/rc.d/init.d/mysql stop
Shutting down MySQL..[ OK ]


2:然後應用mysqld_safe敕令啟動mysql,更新root賬號的暗碼

    --skip-grant-tables:不啟動grant-tables(受權表),跳過權限掌握。

    --skip-networking :跳過TCP/IP協定,只在本機拜訪(這個選項不是必需的。可以不消)是可以不消

[root@DB-Server ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 5145
You have new mail in /var/spool/mail/root
[root@DB-Server ~]# 150709 14:10:53 mysqld_safe Logging to '/var/lib/mysql/DB-Server.localdomain.err'.
150709 14:10:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
 
[root@DB-Server ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.20-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
 
Copyright (c) 2000, 2014, 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> show databases;
+--------------------+
| Database  |
+--------------------+
| information_schema |
| mysql  |
| performance_schema |
| test  |
+--------------------+
4 rows in set (0.00 sec)
 
mysql> use mysql
Database changed
mysql> UPDATE user SET password=PASSWORD("Qwe123") WHERE user='root'; 
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4 Changed: 4 Warnings: 0
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> exit
Bye

3:從新啟動MySQL辦事。

以上所述就是本文的全體內容了,願望年夜家可以或許愛好

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved