Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)

Tags:

mysql

I tried to deploy web application on my server and I am getting this mysql database exception

Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)

I tried to access the database from the command prompt using mysql -u root -p I am able to do all the database operations.

what is the error

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:771)
    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3649)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1176)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2558)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
    at java.sql.DriverManager.getConnection(DriverManager.java:620)
    at java.sql.DriverManager.getConnection(DriverManager.java:200)
    at com.mpigeon.DbConnection.DbConn(DbConnection.java:26)
    at com.mpigeon.CheckLoginHome.doGet(CheckLoginHome.java:39)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
like image 557
Jeevan Dongre Avatar asked May 21 '11 11:05

Jeevan Dongre


People also ask

How do I fix yes access denied for password?

To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password'; Replace user_name with the user's username and password with the user's password.

How do I fix root access denied?

Solution 1: Sudo then Change Password If you get the “access denied” error, one way to solve it is by using sudo to log in to mysql and change the root password. Step 1: Open the command line on your system. Step 3: Enter the password for this account.


3 Answers

You need to grant access to root from localhost. Check this ubuntu help

like image 123
jmj Avatar answered Sep 27 '22 20:09

jmj


try using root like..

mysql -uroot

then you can check different user and host after you logged in by using

select user,host,password from mysql.user;
like image 41
Vivek Buddhadev Avatar answered Sep 27 '22 21:09

Vivek Buddhadev


check you are putting blank space in password.

like image 29
KhAn SaAb Avatar answered Sep 27 '22 20:09

KhAn SaAb