java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

5,988 views
Skip to first unread message

Yaswanth Sai

unread,
Jun 9, 2015, 1:31:26 AM6/9/15
to gce-dis...@googlegroups.com
Hello Guys,

At present i am doing one android application(Client-Server type). 

I deployed two instances namely 

1.)Tomcat Stack - to run servlets
2.)Lamp Stack - to perform jdbc operations

yes,i know ..tomcat stack itself contains mysql thing..but i want phpmyadmin also as my database is very big(lot of fields)..so installed Lamp Stack.

The following are the details given during jdbc connection from servlet.

        String DriverName="com.mysql.jdbc.Driver";
String userName="root";
String password="root";
String driverManager="jdbc:mysql://localhost:3306/databasename";
The lamp stack instance url is http://146.148.35.12/ 

I am getting the following exception

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

Upon googling ,i came to know that we have to grant all privileges.

So granted all privileges from the phpmyadmin itself.


But still the same exception.

As a trail , i created new user 'sai' with password 'sai' of host type 'any host' will all priviledges

        String DriverName="com.mysql.jdbc.Driver";
String userName="sai";
String password="sai";
String driverManager="jdbc:mysql://localhost:3306/databasename";

java.sql.SQLException: Access denied for user 'sai'@'localhost' (using password: YES)

One source on google said that you should keep $cfg['Servers'][$i]['password'] = 'root'; on config.inc.php file

while downloading the config.inc.php file  from the phpmyadmin directory of lamp instance through filezilla,it returns a empty file

I am unable to move to the next steps because of this problem.

So is there anyone who faced similar type of problem or who knows how to solve this problem???

Can any one tell why i am getting an empty config.inc.php file  ????

Kamran (Google Cloud Support)

unread,
Jun 10, 2015, 3:26:47 PM6/10/15
to gce-dis...@googlegroups.com, Yaswanth Sai

If you used the Click-to-Deploy interface to deploy your LAMP stack, you can find your root password by clicking on 'Show password' in the LAMP stack deployment page. Then you can connect to your LAMP server via SSH and verify your username and password by running the following command (before using them in your codes):

$ mysql -u root -p


Sincerely,

Kamran

Lakhveer Singh

unread,
Feb 22, 2016, 5:57:07 AM2/22/16
to gce-discussion
Ther was way to add username password.
First i have connected to localhost database using host as 127.0.0.1. now i am trying to connect to 54.35.xx.xxx Mysql database but i m getting this error.

ERROR java.sql.SQLException: Access denied for user 'root'@'50.16.35.xxx' (using password: NO)

In error massage its trying to connect my local machine again because my local machine IP address is 50.16.35.xxx instead of 54.35.xx.xxx

Can anyone please tell me how this is happening.
Plz help me : lakhveer...@gmail.com

George

unread,
Feb 22, 2016, 7:35:23 PM2/22/16
to gce-discussion
Hello Lakhveer,

If I correctly understood, your Mysql sever has an IP address 54.35.xx.xxx and you are trying to connect to it from your local machine which has an IP 50.16.35.xxx and you are getting access denied. Please correct me if I am wrong.

Did you allow your 50.16.35.xxx IP to access the server 54.35.xx.xxx in the firewall? Where is the Mysql database hosted? is it a Google Cloud SQL or Mysql on a GCE instance?

Sincerely,
George
Reply all
Reply to author
Forward
0 new messages