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

首頁 > 數據庫 > MySQL > 正文

Mysql5.7忘記root密碼及mysql5.7修改root密碼的方法

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

關閉正在運行的 MySQL :

[root@www.woai.it ~]# service mysql stop

運行

[root@www.woai.it ~]# mysqld_safe --skip-grant-tables &

為了安全可以這樣禁止遠程連接:

[root@www.woai.it ~]# mysqld_safe --skip-grant-tables --skip-networking &

使用mysql連接server:

[root@www.woai.it ~]# mysql -p

更改密碼:

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';

*特別提醒注意的一點是,新版的mysql數據庫下的user表中已經沒有Password字段了

而是將加密后的用戶密碼存儲于authentication_string字段

mysql> flush privileges;mysql> quit;

修改完畢。重啟

[root@localhost ~]# service mysql restart

然后mysql就可以連接了

但此時操作似乎功能不完全,還要alter user…

mysql> alter user 'root'@'localhost' identified by '123';

這樣也可以:

mysql> set password for 'root'@'localhost'=password('123');

重點給大家介紹下mysql 5.7 root密碼修改

MySQL管理者密碼設置或修改:

依據官方說明5.6以后版本,第一次啟動時會在root目錄下生產一個隨機密碼,文件名.mysql_secret。

[root@bright ~]# cat /root/.mysql_secret# Password set for user 'root@localhost' at 2015-03-27 23:12:10:Jj+FTiqvyrF[root@bright ~]# cd /usr/local/mysql/bin/[root@bright bin]# ./mysqladmin -u root -h localhost password '123456' -p

Enter password: #此行輸入.mysql_secret里第二行內容

mysqladmin: [Warning] Using a password on the command line interface can be insecure.Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

官方的方式,筆者無論是否使用--skip-grant-tables啟動mysql都測試失敗,親們可以測試:

shell>mysql -uroot -p'password' #password即.mysql_secret里的密碼mysql>SET PASSWORD = PASSWORD('newpasswd');

舊版本,安裝后ROOT無密碼,按如下操作:

方法一:

shell>service mysqld stop #停止mysql服務shell>mysqld_safe --skip-grant-tables & #以不啟用grant-tables模式啟動mysqlshell>mysql -uroot -p #輸入命令回車進入,出現輸入密碼提示直接回車。mysql>use mysql;mysql>update user set password=PASSWORD("123456")where user="root"; #更改密碼為 newpassordmysql>flush privileges; #更新權限mysql>quit #退出

方法二:

shell>service mysqld stop #停止mysql服務shell>mysqld_safe --skip-grant-tables & #以不啟用grant-tables模式啟動mysqlshell>mysql -uroot -p #輸入命令回車進入,出現輸入密碼提示直接回車。mysql > set password for root@localhost = password('mysqlroot');

方法三:

shell>/path/mysqladmin -u UserName -h Host password 'new_password' -p
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 耒阳市| 右玉县| 鄄城县| 三江| 漳州市| 辽中县| 内黄县| 手机| 高阳县| 淅川县| 常州市| 逊克县| 华蓥市| 平遥县| 汉阴县| 珠海市| 周宁县| 彰化县| 纳雍县| 海安县| 社旗县| 晋宁县| 库伦旗| 福安市| 兰州市| 雷州市| 宁津县| 峨山| 赣榆县| 浑源县| 宕昌县| 巴楚县| 深州市| 兴海县| 徐水县| 正蓝旗| 昔阳县| 八宿县| 如东县| 榆中县| 万载县|