91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

關于mysql中root權限丟失的問題

發布時間:2020-08-11 22:57:34 來源:ITPUB博客 閱讀:150 作者:mohan213 欄目:MySQL數據庫
剛聽一哥們說執行了一條語句:revoke all on *.* from root@localhost;            --呵呵,當時到底是怎樣的心理活動,這是怎樣的恨。。。
于是小菜就做了一個實驗,心里感覺應該和密碼丟失后跳過權限重新設置密碼的解決方法是一樣的,當然這只是思路,試試才知道。
首先停止數據庫[root@mysql ~]#service mysql3306 stop                              --因為忘記密碼所以只能停止服務的方式關閉數據庫
Shutting down MySQL.                                       [  OK  ]
[root@mysql ~]#
[root@mysql ~]# /usr/local/mysql/bin/mysqld_safe  --defaults-file=/usr/local/mysql/etc/my.cnf  --skip-grant-tables &                         --跳過校驗密碼的方式啟動數據庫[2] 11254
[root@mysql ~]# 160330 16:56:22 mysqld_safe Logging to '/usr/local/mysql/log/err3306.log'.
160330 16:56:22 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

[root@mysql ~]# ps -ef | grep mysql                                               --查看數據庫已然啟動
root      11254   6904  0 16:56 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
mysql     11771  11254  0 16:56 pts/2    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --skip-grant-tables --log-error=/usr/local/mysql/log/err3306.log --pid-file=/usr/local/mysql/data/mysql.lz.com.pid --socket=/usr/local/mysql/mysqld3306.sock --port=3306
root      11795   6904  0 16:57 pts/2    00:00:00 grep mysql
[root@mysql ~]# /usr/local/mysql/bin/mysql --socket=/usr/local/mysql/mysqld3306.sock --port=3306                   --不指定用戶和密碼直接登錄數據庫
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.17-log Source distribution

Copyright (c) 2000, 2011, 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> select user();                                                --默認為root用戶登錄
+--------+
| user() |
+--------+
| root@  |
+--------+
1 row in set (0.00 sec)

root@master 08:41:31 >grant all on *.* to 'root'@'localhost';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement  
在網上找到解決方法:

這個時候我們只需要

flush privileges 一下,在添加用戶就OK了,

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

root@master 08:45:59 >grant all on *.* to 'ivan'@'localhost' identified by 'mysql321'  with grant option;
Query OK, 0 rows affected (0.01 sec)

root@master 08:46:24 >flush privileges;
Query OK, 0 rows affected (0.01 sec)

root@master 08:46:31 >quit
Bye
[root@mysql data]# service mysql3306 stop
Shutting down MySQL..160409 08:46:39 mysqld_safe mysqld from pid file /usr/local/mysql/mysql3306.pid ended
                                                           [  OK  ]
[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --skip-grant-tables
[root@mysql data]# ps -ef  |grep msyql
root      62709  57953  0 08:46 pts/1    00:00:00 grep msyql
[root@mysql data]# service mysql3306 start
Starting MySQL..                                           [  OK  ]
[root@mysql data]# /usr/local/mysql/bin/mysql -uivan -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.17-log Source distribution

Copyright (c) 2000, 2011, 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.

ivan@master 08:47:36 >grant all on *.* to 'root'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)

[root@mysql data]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.17-log Source distribution

Copyright (c) 2000, 2011, 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.

root@master 08:49:33 >show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| c_test             |
| ivan               |
| mysql              |
| performance_schema |
| test               |
| webcat             |
+--------------------+
至此一切正常。。。。。啊哈哈哈哈。。。。


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

中西区| 黔江区| 永仁县| 四子王旗| 中山市| 胶南市| 淳安县| 陈巴尔虎旗| 呼伦贝尔市| 台东市| 汝阳县| 嵊泗县| 云林县| 永安市| 阿瓦提县| 万州区| 图们市| 晋宁县| 临城县| 枝江市| 江永县| 清水县| 精河县| 周宁县| 梁山县| 沾化县| 株洲市| 龙江县| 张家口市| 临猗县| 宣武区| 西宁市| 凭祥市| 枞阳县| 秦皇岛市| 丁青县| 鄂州市| 鲜城| 宾阳县| 乾安县| 长宁县|