国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL修改root賬號密碼的方法

2020-01-18 22:49:14
字體:
來源:轉載
供稿:網友

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 namesYou can turn off this feature to get a quicker startup with -A Database changedmysql> 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 stopShutting down MySQL..[ OK ][root@DB-Server ~]# 


[root@DB-Server ~]# /etc/rc.d/init.d/mysql stopShutting 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] 5145You 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 mysqlReading table information for completion of table and column namesYou 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 1Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners. 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 mysqlDatabase changedmysql> 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> exitBye

3:重新啟動MySQL服務。

以上所述就是本文的全部內容了,希望大家能夠喜歡

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 满城县| 灵川县| 蒲城县| 招远市| 额尔古纳市| 鹿邑县| 庆元县| 苏尼特左旗| 连山| 天台县| 遂宁市| 库车县| 繁昌县| 海门市| 星子县| 定远县| 淮安市| 玉树县| 加查县| 晋宁县| 绵竹市| 新建县| 宁海县| 册亨县| 镇原县| 博兴县| 顺义区| 九龙坡区| 云和县| 五大连池市| 马关县| 文水县| 施甸县| 屏山县| 刚察县| 会东县| 嘉善县| 灌南县| 长岛县| 梁山县| 牟定县|