Fixing Mysql 1045 Error: Access Denied

     

Hi guys, I am very new to using a service lượt thích nguyenminhchau.com (opposed to a one clichồng cài đặt of mediatemple or godaddy) & I am trying to thiết đặt and configure a new DB using MySquốc lộ but I keep getting the error

ERROR 1045 (28000): Access denied for web1_user "root"
"localhost" (using password: YES)I have sầu googled this, và searched the community for answers but cannot seem khổng lồ solve this issue. Am I missing something? I have sầu tried running it as root, và running it with sudo through another web1_user and cannot get around it. If I offer no password it gives the same error but instead of using password: YES, it’s NO.

Thanks.

Bạn đang xem: Fixing Mysql 1045 Error: Access Denied


*

Join the nguyenminhchau.com Community
*

Join 1M+ other developers and:

Get help & tóm tắt knowledge in Q&ASubscribe to lớn topics of interestGet courses và tools that help you grow as a developer or small business owner Join Now
Install MySquốc lộ on New Droplet Question
How can I solve sầu error "SQLSTATE <2002> Can't connect lớn local MySQL VPS through socket '/var/lib/mysql/mysql.sock' (2)" Question

Am using Ubuntu-16.04 : installed mysql - 5.7. I Had the same issue.

Tried the below steps:

dpkg –get-selections | grep mysql (to get the version of mysql).

dpkg-reconfigure mysql-server-5.7

mysql -u root -p

Without -p that doesn’t prompt you lớn ask password. Once you are in, you can create a web1_user with a password by following steps :

CREATE USER ’-your_name-’
‘your-hostname’ IDENTIFIED BY "your-password’;

GRANT ALL PRIVILEGES ON . to ’-your_name-’
"your-hostname’ WITH GRANT OPTION;

Exit from the root và login from the you gave above sầu.

mysql -u -p

For some reason still just typing mysql does not work. AT ALL. Please let me know if this works, else I have sầu other steps.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into lớn issues leave sầu a phản hồi, or add your own answer to lớn help others.

×

You can type !ref in this text area to lớn quickly search our full phối of tutorials, documentation và marketplace offerings và insert the link!


Which one-click-setup did you use? You can check the configuration files probably & find the password. If you can’t find it, neither root without pass is working you can rephối it:

Commands

suvì /etc/init.d/mysql stopNow start up MySQL in safe mode, so you’ll skip the privileges table:

suvày mysqld_safe --skip-grant-tables &Login with root:

mysql -urootAnd assign the DB that needs to lớn be used:

use mysql;Now all you have sầu to do is remix your root password of the MySQL web1_user and restart the MySQL service:

update web1_user set password=PASSWORD("YOURPASSWORDHERE") where User="root";flush privileges;quit and restart MySQL:

quitsuvị /etc/init.d/mysql stopsubởi vì /etc/init.d/mysql startNow your root password should be working with the one you just mix, kiểm tra it with:

mysql -u root -pHope this will help you figure it out.


Reply Report
0
Gopichand March 2, 2017

it’s working. But after logout my mysql again it will be showing same ERROR ? So plzzzz Help ME !!!!


Reply
Report
4
gvionut November 29, 2016

On MySql 5.7 version you must replace query to:

update web1_user mix authentication_string=PASSWORD("YOURPASSWORDHERE") where web1_user="root"; everything else it’s lượt thích CrypticDesigns described..


Reply
Report
0
Woet December 3, 2015

Use the right password.


Reply
Report
0
paulchabot January 21, 2016

I was tripped up on a brand new installation of mysql. There will be a temporary root password created & logged in /var/log/mysqld.log kiểm tra there và once mysql is started (as a service) you can then start mysqlsecureinstallation and use the password from the log tệp tin lớn thiết lập mysql.

Xem thêm:


Reply
Report
0
prakashluitel88 February 8, 2016

Thanks CrypticDesigns. It worked well for me.


Reply
Report
0
rfloresvqz May 3, 2016

It worked for me. Thanks


Reply
Report
0
Seavet June 4, 2017

I have sầu the same problem as described above sầu on my Ubuntu 16.04 LTS/MySquốc lộ 5.7.18/WordPress droplet, with 2 CPU, 40GB SSD and 16GB RAM. The droplet is only running one site & has hardly any traffic because it is still under development.

I cannot connect via ‘mysql -u root -p’.I cannot use the "suvì chưng mysqlsecureinstallation’ script.Every time after entering the password I get the dreaded “Access denied for web1_user "root’
"localhost’ (using password: YES)” error message.

This seems lớn be a very common problem. I followed all the usual recommendation, such as reinstalling MySQL, with và without prior uninstall, crossgrading lớn MariaDB and baông chồng khổng lồ MySQL, all lớn none avail. What am I doing wrong?

Btw, the WordPress site is working fine. The problem only became apparent when I added Moodle lớn the installation và got stuông xã at the point where you need to create the moodle tables. Since I cannot log into the MySquốc lộ hệ thống, I’m now stuông chồng.


Reply
Report
0
rushmith June 21, 2017

Installed mysql - 5.7. I Had the same issue.

Tried the below steps:

1. dpkilogam –get-selections | grep mysql (to lớn get the version of mysql).

2. dpkg-reconfigure mysql-server-5.7

3. mysql -u root -p

Without -p that doesn’t prompt you khổng lồ ask password. Once you are in, you can create a web1_user with a password by following steps :

CREATE USER ’-your_name-’
‘your-hostname’ IDENTIFIED BY "your-password’;

GRANT ALL PRIVILEGES ON . to lớn ’-your_name-’
"your-hostname’ WITH GRANT OPTION;

Exit from the root và login from the you gave above.

mysql -u -p

For some reason still just typing mysql does not work. AT ALL. Please let me know if this works, else I have sầu other steps.


Reply
Report
0
anjali505 October 31, 2017

after step 3 it gives Can’t connect khổng lồ local MySquốc lộ hệ thống through socket ’/var/run/mysqld/mysqld.sock’ (2)

what lớn do??


Reply
Report
0
uncersh October 29, 2018

I used mysql -u root -p and enter password and got working.


Reply
Report
0
rawhasanweb July 28, 20đôi mươi

I am also new in nguyenminhchau.com và was following this article lớn thiết đặt a LEMP server: https://www.nguyenminhchau.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-20-04

I was having trouble on the last step. I was unable to connect to the database using the php script. It was showing the following error:

“Error!: SQLSTATE <1045> Access denied for web1_user”

I was able khổng lồ log-in from the terminal using the same credential và was able to see the records on the table, but the php script was showing the connection error for the same credential, which was weird!

After searching all the posts on stackoverflow, found no solution for this. Finally don’t know why, I ran the php tệp tin from the terminal like this instead of the browser:

‘php /var/www/yourdomain/tododanh sách.php’

which was showing me an error on line 3, which was the line with the password. It was telling me something like an empty value và indicating the last 2 characters of the password. I then noticed that in my password, before these last two characters, I have sầu a “$” sign, which is the reserved symbol in php to lớn indicate a variable!