During our work in support, we see this again and again: “I try to connect to MySQL and am getting a 1045 error”, and most times it comes accompanied with “…but I am sure my web1_user and password are OK”. So we decided it was worth showing other reasons this error may occur.
Đang xem: Solved: error 1045 (28000): access denied for web1_user “root”@
1) Connecting to wrong host:
nguyenminhchau.com># mysql -u root -psekretmysql:
If not specifying the host to connect (with -h flag), MySQL client will try to connect to the localhost instance while you may be trying to connect to another host/port instance.
Xem thêm: Top 5 Plugins Editor WordPress Thân Thiện Dễ Sử Dụng Nhất 2020
Fix: Double check if you are trying to connect to localhost, or be sure to specify host and port if it’s not localhost:
nguyenminhchau.com># mysql -u nonexistant -psekret -h localhostmysql:
nguyenminhchau.com># mysql -u nonexistant -psekretmysql:
mysql> SELECT Host, User FROM mysql.web1_user WHERE User=”nonexistant”;+————-+————-+| Host | User |+————-+————-+| 192.168.0.1 | nonexistant |+————-+————-+1 row in set (0.00 sec)
If you need to check from which IP the client is connecting, you can use the following Linux commands for server IP:
nguyenminhchau.com># ip address | grep inet | grep -v inet6 inet 127.0.0.1/8 scope host lo inet 192.168.0.20/24 brd 192.168.0.255 scope global dynamic wlp58s0
You can then create a web1_user with correct Host (client IP), or with ‘%’ (wildcard) to match any possible IP:
nguyenminhchau.com># mysql -u nonexistant -pforgottenmysql:
Fix: Check and/or reset password:
You cannot read web1_user passwords in plain text from MySQL as the password hash is used for authentication, but you can compare hash strings with “PASSWORD” function:
mysql> SELECT Host, User, authentication_string, PASSWORD(“forgotten”) FROM mysql.web1_user WHERE User=”nonexistant”; +————-+————-+——————————————-+——————————————-+| Host | User | authentication_string | PASSWORD(“forgotten”) |+————-+————-+——————————————-+——————————————-+| 192.168.0.1 | nonexistant | *AF9E01EA8519CE58E3739F4034EFD3D6B4CA6324 | *70F9DD10B4688C7F12E8ED6C26C6ABBD9D9C7A41 || % | nonexistant | *AF9E01EA8519CE58E3739F4034EFD3D6B4CA6324 | *70F9DD10B4688C7F12E8ED6C26C6ABBD9D9C7A41 |+————-+————-+——————————————-+——————————————-+2 rows in set, 1 warning (0.00 sec)
mysql> SELECT Host, User, authentication_string, PASSWORD(“forgotten”) FROM mysql.web1_user WHERE User=”nonexistant”;
+————-+————-+——————————————-+——————————————-+
+————-+————-+——————————————-+——————————————-+
| 192.168.0.1 | nonexistant | *AF9E01EA8519CE58E3739F4034EFD3D6B4CA6324 | *70F9DD10B4688C7F12E8ED6C26C6ABBD9D9C7A41 |
| % | nonexistant | *AF9E01EA8519CE58E3739F4034EFD3D6B4CA6324 | *70F9DD10B4688C7F12E8ED6C26C6ABBD9D9C7A41 |
+————-+————-+——————————————-+——————————————-+
We can see that PASSWORD(‘forgotten’) hash does not match the authentication_string column, which means password string=’forgotten’ is not the correct password to log in. Also, in case the web1_user has multiple hosts (with different password), he may be trying to connect using the password for the wrong host.
Xem thêm: Tuyển Tập Các Đề Thi Tiếng Anh Thpt Quốc Gia 2020, Đề Thi & Đáp Án Môn Tiếng Anh Thpt Quốc Gia 2020
In case you need to override the password you can execute the following query:
nguyenminhchau.com># mysql -u nonexistant -phello$!world mysql:
nguyenminhchau.com># mysql -u nonexistant -p”hello$!world”mysql:
nguyenminhchau.com># mysql -u sslweb1_user -psekretmysql:
You can read more in-depth on how to configure SSL in MySQL in the blog post about “Setting up MySQL SSL and Secure Connections” and “SSL in 5.6 and 5.7“.
Related posts
Bảng Giá Tên Miền Việt Nam Và Quốc Tế Tại Mắt Bão, Bảng Giá Tên Miền Tại P
ContentsMySQL 1045 error Access Denied triggers in the following cases: P.A Việt Nam tiên phong trong thị trường Internet...
Hướng Dẫn Tạo File Ghost Win 10 Đa Cấu Hình Win 7/8/10 Bằng Easy Sysprep
ContentsMySQL 1045 error Access Denied triggers in the following cases: “Cách tạo bản ghost đa cấu hình Windows 10...
Domain Controller Là Gì – Tìm Hiểu Mục Đích Sử Dụng
ContentsMySQL 1045 error Access Denied triggers in the following cases: Để hiểu rõ về khái niệm Domain Controller, chúng...
ContentsMySQL 1045 error Access Denied triggers in the following cases: Nội Dung Chính Download Onekey Ghost Win 10, 7...
Hướng Dẫn Cách Ghost Bang Onekey Tốc Độ Cao, Hướng Dẫn Cách Ghost Win 7 Bằng Onekey Ghost
ContentsMySQL 1045 error Access Denied triggers in the following cases: Cách dùng phần mềm OneKey Ghost để ghost Windows...
Hướng Dẫn Ghost Bằng Hiren Boot 15.2, Giup Do Ghost Win 8 Bang Hiren Boot Cd 15
ContentsMySQL 1045 error Access Denied triggers in the following cases: admin.ta 30 Tháng Ba, 2021 Leave a Comment on...