1. 程式人生 > >MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

先開一個cmd視窗A:

//開啟MySQL
C:\WINDOWS\system32>net start mysql
MySQL 服務正在啟動 ...
MySQL 服務已經啟動成功。

//登陸報錯
C:\WINDOWS\system32>mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

//關閉MySQL
C:\WINDOWS\system32>net stop mysql
MySQL 服務正在停止.
MySQL 服務已成功停止。

//無密碼啟動MySQL服務
C:\WINDOWS\system32>mysqld --console --skip-grant-tables --shared-memory
2018-11-22T14:06:27.964267Z 0 [System] [MY-010116] [Server] 
D:\mysql-8.0.13-winx64\bin\mysqld.exe (mysqld 8.0.13) starting as process 2972
2018-11-22T14:06:30.981556Z 0 [Warning] [MY-010068] [Server] 
CA certificate ca.pem is self signed.
2018-11-22T14:06:31.006330Z 0 [System] [MY-010931] [Server] 
D:\mysql-8.0.13-winx64\bin\mysqld.exe: ready for connections. 
Version: '8.0.13'  socket: ''  port: 0  MySQL Community Server - GPL.
2018-11-22T14:06:31.209604Z 0 [Warning] [MY-011311] [Server] 
Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible'


再開一個cmd視窗B:

//無密碼【登陸】(密碼處直接enter)
C:\WINDOWS\system32>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, 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> UPDATE mysql.user SET authentication_string='' WHERE user='root' and host='localhost';
Query OK, 1 row affected (0.08 sec)
Rows matched: 1  Changed: 1  Warnings: 0

//重新整理
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)

//查詢
mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host      | user             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | caching_sha2_password |                                                                        |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

//---------------------------------------------設定加密的密碼---------------------------------------------
//以caching_sha2_password加密密碼並設定
mysql> ALTER user 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'admin';
Query OK, 0 rows affected (0.17 sec)

//重新整理
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

//查詢
mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host      | user             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | caching_sha2_password | $A$005$r/r8"We_EpPb9584lw2cALUsOsvkB/hHg1qUqocVxDMMkFQ8RyQcXASZoff5 |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

關閉A/B cmd視窗,再開一個cmd 視窗C

//登陸成功
C:\WINDOWS\system32>mysql -uroot -padmin
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, 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> ALTER user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';
Query OK, 0 rows affected (0.12 sec)

//重新整理
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)

//查詢
mysql> select host,user,plugin,authentication_string from mysql.user;
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| host      | user             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root             | mysql_native_password | *4ACFE3202A5FF5CF467898FC58AAB1D615029441                              |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
4 rows in set (0.00 sec)

mysql>

其他常用cmd命令

//---------------------------------------常用語句------------------------------------------------------------
//修改加密規則
mysql> UPDATE mysql.user SET plugin='mysql_native_password' WHERE user='root';

//查詢
mysql> select host,user,plugin,authentication_string from mysql.user;

//對密碼進行加密
mysql> update mysql.user set password=password('admin') where user='root' and host='localhost';  

//重新整理
flush privileges;

//退出
mysql> exit

注意:

mysql> use mysql;  
mysql> update user set password=password('123') where user='root' and host='localhost';  
//等價於
mysql> update mysql.user set password=password('123') where user='root' and host='localhost';  
C:\WINDOWS\system32>mysql -uroot -padmin 
//等價於
C:\WINDOWS\system32>mysql -u root -p admin

相關推薦

MySQL 8.0.13 密碼問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

先開一個cmd視窗A: //開啟MySQL C:\WINDOWS\system32>net start mysql MySQL 服務正在啟動 ... MySQL 服務已經啟動成功。 //登陸報錯 C:\WINDOWS\system32>mysql

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)的真正原因

[[email protected] tmp]# rpm -ivh MySQL-server-advanced-5.6.20-1.rhel5.x86_64.rpmPreparing...                #########################################

Linux mysql 5.6: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

tail -200 /var/lib/mysql/DB-Server.err | more2014-07-22 14:59:41 9346 [Note] Shutting down plugin 'binlog'2014-07-22 14:59:41 9346 [Note] /usr/sbin/mysqld:

MySQL登入 ERROR 1045 (28000) Access denied for user 'root'@'localhost' (using password NO)問題

一、問題今天在CentOS安裝了mysql,由於mysql剛剛安裝完的時候,mysql的root使用者的密碼預設是空的,所以我使用命令mysql -uroot或mysql登入mysql,但是出現瞭如下錯誤:ERROR 1045(28000): Access denied fo

MySQL 報錯 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 的解決辦法

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 這次申請的 CentOS 6。7 虛擬機器映象 自帶了 MySQL ,然而進入這個虛擬機器

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

http://blog.csdn.net/qq160816/article/details/7722680 錯誤描述: Mysql中新增使用者之後可能出現登入時提示ERROR 1045 (28000): Access denied for user的錯誤.刪除user

MYSQL重置密碼 MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)

一般這個錯誤是由密碼錯誤引起,解決的辦法自然就是重置密碼。 假設我們使用的是root賬戶。 1.重置密碼的第一步就是跳過MySQL的密碼認證過程,方法如下: #vim /etc/my.cnf(注:windows下修改的是my.ini) 在文件內搜尋mysqld定位

登入mysql資料庫出現 : ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) ER

登入mysql資料庫的時候出現 : ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost'(using password: NO) ERROR 1045 (28000): Access denied for

MySQL的啟動問題 (ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO))

2011-03-18 wcdj 解決方法如下 : (1) 開啟mysql的服務,因為我當時安裝選擇的手動啟動。 (2) 將mysql安裝的bin目錄新增到系統PATH環境變數裡,用;(分號)分割。 (

Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES) 翻譯: 錯誤1045(28000):對使用者“root”@本地主機拒絕訪問(使用密碼:是) 一

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)問題的解決辦法

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)該故障碼的意思是拒絕訪問資料庫。 一般出現該故障碼是由於資料庫的賬號或密碼被更改過所致。解決的辦法是更改資

遇到問題---mysql賬戶密碼以及許可權的問題 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor 這種型別的提示是帳號密碼不對或者帳號不存在的現象。 我們先來梳理一下mysql的賬戶密碼思路  mysql安裝完後 ro

MySQL修改密碼後無法進入問題ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)

MySQL之前無密碼,使用 UPDATE mysql.user SET authentication_string=’xxxx’ WHERE user=’root’ and host=’localhost’; 修改增加密碼後登入一直報錯, root以

重置密碼解決MySQL for Linux錯誤 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor

一般這個錯誤是由密碼錯誤引起,解決的辦法自然就是重置密碼。 假設我們使用的是root賬戶。 1.重置密碼的第一步就是跳過MySQL的密碼認證過程,方法如下: #vim /etc/my.cnf(注:windows下修改的是my.ini) 在文件內搜尋mysqld定

解決MySQL登入ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)問題

問題描述 今天在MAC上安裝完MYSQL後,MYSQL預設給分配了一個預設密碼,但當自己在終端上使用預設密碼登入的時候,總會提示一個授權失敗的錯誤:Access denied for user ‘root’@’localhost’ (using passwor)如圖

centos7 上安裝mysql5.7後登入報錯ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pas

安裝完mysql後會有個臨時密碼去日誌檢視,但是檢視登入修改密後還是不行 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes) 於是 1,停止mysql服務 sy

Ubuntu server裡登入mySql時報錯:Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'的纖細解決方案

問題如下: 輸入正確密碼後,卻出現錯誤 首先我們用vi編輯器進入mysql的配置檔案mysqld.cnf 我們在檔案裡內容找到mysqld這一目錄,在其目錄下新增一行skip-grant-tables 隨後按esc鍵輸入:wq儲存退出 退出後

mysql】linux用yum安裝mysql後,登陸root使用者提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (..

系統是CentOS 6.8 yum -y install mysql mysql-server mysql-devel 安裝完之後 [root@iZwz9gjh3pbz2k2hin7cg8Z ~]# mysql -uroot -p 報

mysql連線問題 ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using pas

剛使用mysql,遇到如下問題: C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (usi

windows系統下mysql出現Error 1045(28000) Access Denied for user 'root'@'localhost'

在windows作業系統安裝mysql資料庫,碰到Error 1045(28000) Access Denied for user 'root'@'localhost' 錯誤時,需要重新設定密碼。 具體方法是: 1.先在安裝目錄找到my.ini配置檔案,開啟配置檔案,找到[mysqld]一行,在下面新增