連線MySQL資料常見問題

2021-10-25 13:28:31 字數 2708 閱讀 9683

錯誤資訊1 :error 1045 (28000): access denied for user 'usera'@'localhost'

(using password:yes)

錯誤資訊2 :error 1045 (28000): access denied for user 'usera'@'localhost'

(using password:no)

總結:對於 error 1045 (28000): access denied for user 'root'@'127.0.0.1'  此類錯誤返回時, (using password: ?)中?的

關鍵字是yes還是no,關鍵不在於使用者是否存在,密碼是否正確,它的結果取決於登入時,使用者對於密碼有沒有字串的輸入,

如果沒有,mysql資料庫驗證後,若出錯返回此類資訊,則應是 (using password: no),若使用者對密碼有字串的輸入,返回的則是

(using password: yes)。

原因1 : 客戶端遠端訪問的使用者賬號並未建立
檢查

以管理員root登入後,show grants for

'user'@』ip『; 或者 select user from mysql.user; 確認使用者賬號是否存在。

mysql> show grants for

'test'@'127.0.0.1'

;error 1141 (42000): there is no such grant defined for user 'test' on host '127.0.0.1'

mysql>

返回資訊:error 1141 (42000): there is no such grant defined for user 'test' on host '127.0.0.1'

說明,沒有jtsec使用者,或者沒有對jtsec使用者進行在192.168.8.123遠端訪問的授權。

解決

mysql>  grant all privileges on *.* to 'test'@'127.0.0.1' identified by 'test' with grant option;

mysql> flush privileges;

mysql> show grants for

'test'@'127.0.0.1'

;mysql>

select user,host from mysql.user;

原因2 : 使用者賬號存在,但未對其所在的客戶端的ip進行遠端訪問授權允許
檢查

以管理員root登入後 show grants for

'user'@'ip'

;mysql> show grants for

'root'@'127.0.0.1'

;error 1141 (42000): there is no such grant defined for user 'root' on host '127.0.0.1'

返回資訊:error 1141 (42000): there is no such grant defined for user 'root' on host '127.0.0.1'

說明,沒有root使用者,或者沒有對root使用者進行在127.0.0.1遠端訪問的授權。

mysql> show grants for

'root'@'localhost'

;或者直接查詢mysql的user使用者表select user,host from mysql.user;

mysql>

select user,host from mysql.user;

複製**

解決

進行root使用者的遠端訪問授權,可以授權到指定的客戶端ip,也可以授權為所有ip都可訪問(host值為%)。

授權為所有ip都使用使用者root,密碼root,來遠端訪問資料庫

mysql> grant all privileges on *.* to'root'@'%' identified by 'root' with grant option;

mysql> flush privileges;

再次進行授權的查詢

mysql> show grants for

'root'@'%'

;再次查詢授權表記錄

mysql>

select user,host,password from mysql.user;

注意:mysql5.7用下面這條語句查詢

mysql>

select user,host,authentication_string from mysql.user;

原因3 : 使用者賬號授權訪問的密碼不正確
檢查

以管理員root登入後, select user,host, authentication_string  from mysql.user;

mysql>

select user,host, authentication_string from mysql.user;

解決

使用正確的訪問密碼進行訪問即可。

MySQL傳輸資料常見問題

timestamp 0 not null default current timestamp no zero in date 在嚴格模式,不接受月或日部分為0的日期。如果使用ignore選項,我們為類似的日期插入 0000 00 00 在非嚴格模式,可以接受該日期,但會生成警告。no zero da...

Mysql常見問題

1.安裝,推薦使用非安裝版.把解壓後的檔案拷貝到c盤根目錄下,並把總目錄改為mysql.然後進入windows命令 控制台,在c mysql bin下面執行mysqld nt install把它安裝為乙個服務,然後呼叫net start mysql啟動它,停止的命令是net stop mysql 想...

mysql常見問題

按照表中某一欄位排序,若該字段可能存在空值,公升序排列時空值排在最前面,降序排列是空值排在最後面。公升序排列時如果想讓空值排在最後面,可以 order by field1 is null,field1 asc 這麼寫。例如有個user表,按照 seq欄位排序。select from user ord...