《Mysql必讀MySQL修改root賬號(hào)密碼的方法》要點(diǎn):
本文介紹了Mysql必讀MySQL修改root賬號(hào)密碼的方法,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
MYSQL必讀MySQL數(shù)據(jù)庫(kù)中如何修改root用戶的密碼呢?下面總結(jié)了修改root用戶密碼的一些方法
MYSQL必讀1: 使用set password語(yǔ)句修改
MYSQL必讀
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
MYSQL必讀
MYSQL必讀2: 更新mysql數(shù)據(jù)庫(kù)的user表
MYSQL必讀
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
MYSQL必讀
MYSQL必讀3:使用mysqladmin命令修改
MYSQL必讀命令一般為 mysqladmin -u root -p'oldpassword' password newpass 如下所示:
MYSQL必讀
[root@DB-Server ~]# mysqladmin -u root -p'123456' password 'Qwe123'
Warning: Using a password on the command line interface can be insecure.
MYSQL必讀驗(yàn)證root密碼修改是否成功
MYSQL必讀
[root@DB-Server ~]# mysqladmin -u root -p'123456' password 'Qwe123'
Warning: Using a password on the command line interface can be insecure.
MYSQL必讀
?
MYSQL必讀上面都是在知道root密碼的情況下修改root密碼,如果忘記了root密碼,如何修改root的密碼呢?
MYSQL必讀1:首先停掉MySQL服務(wù)
MYSQL必讀
[root@DB-Server ~]# service mysql stop
Shutting down MySQL..[ OK ]
[root@DB-Server ~]#
MYSQL必讀或
MYSQL必讀
[root@DB-Server ~]# /etc/rc.d/init.d/mysql stop
Shutting down MySQL..[ OK ]
MYSQL必讀2:然后使用mysqld_safe命令啟動(dòng)mysql,更新root賬號(hào)的密碼
MYSQL必讀??? --skip-grant-tables:不啟動(dòng)grant-tables(授權(quán)表),跳過(guò)權(quán)限控制.
MYSQL必讀??? --skip-networking :跳過(guò)TCP/IP協(xié)議,只在本機(jī)訪問(wèn)(這個(gè)選項(xiàng)不是必須的.可以不用)是可以不用
MYSQL必讀
[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
MYSQL必讀3:重新啟動(dòng)MySQL服務(wù).
MYSQL必讀以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/6356.html