i am trying to create a database connection , but database is not in my localhost, so i provided the IP instead of localhost in
Connection con= DriverManager.getConnection(conStr, user, pass);
where
constr="jdbc:mysql://54.86.136.55/oms"
but its giving an exception:
java.sql.SQLException: Access denied for user 'ac4773IU'#'125.63.90.34' (using password: NO)
but i login with the same user name and password
Related
I have a remote mysql database on mydomain.com power by goDaddy and have a database name "arsenal101" with several tables and I have assigned the user "arsenal101" with password "22216888" with full privilege to that database.
In my local MySQl workbench in Macbook, I try connecting my MySQL workbench to that remote database.
Here is the screenshot
The hostname I enter mydomain.com
The username is arsenal101
The password is 22216888
The default schema is blank.
After I pressed test connection, an error message showed up " Failed to Connect to MySQL at mydomain.com: 3306 with user arsenal101
access denied for user arsenal101#xxxxxxx (using password Yes)
You should check if GoDaddy allows you to do a remote connection to the database because a lot of hosting companies don't allow that. Their MySQL has to be configured to receive external connections.
According to here: https://in.godaddy.com/help/connect-remotely-to-databases-4978
If you want to connect remotely to a database, you must enable Direct Database Access when setting it up1 — you cannot enable it later.
I have been trying to to connect to MySql data base which uses ssl connection with java and having trouble, if any one can help me will be of great help.
Manual Connection to MySql:
We use MySQL Workbench , parameters - Hostname - "test-db1-ro-xxxxxx.net" , Port - 3306 , User Name , Password.
There is a SSL CA File - mysql-ssl-ca-cert.pem , the manual connection is successful.
I tried the same in java (in windows system)
My code:
String url = "jdbc:mysql://test-db1-ro.apdev.XXXXXX.net:3306/database";
String driver = "com.mysql.jdbc.Driver";
String userName = "XXXXXXXX";
String password = "XXXXXXXX";
Class.forName(driver).newInstance();
Connection conn = DriverManager.getConnection(url,userName,password);
when i run the code i get an error as "Access Denied"
I am thinking it is due to the SSL Connection.
I am not able to know how to use the .pem file to make a secure connection to database in this case.
Can some one help, have done various things but always get the same access denied error.
Full StackTrace:
java.sql.SQLException: Access denied for user 'xxxxxxxx' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3421)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1247)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at TestDBConnection.main(TestDBConnection.java:34)
You have trouble authenticating.
On the MySql terminal:
GRANT ALL ON *.* TO 'user'#'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
If problem still persists:
GRANT ALL ON *.* TO 'user'#'%' WITH GRANT OPTION;
This command grants you superuser privileges.
FLUSH PRIVILEGES;
To make sure your privileges are loaded.
NB: Do not use this account on websites with public access.
i am trying to create a database connection , but database is not in my localhost, so i provided the IP instead of localhost in
Connection con= DriverManager.getConnection(conStr,user,pass);
where
constr="jdbc:mysql://10.0.0.1/Sigma"
but its giving
java.sql.SQLException: Access denied for user 'root'#'15.3.0.4' (using password: NO)
but i login with the same user name and password
That's probably because the machine where you're running that code is has not that 15.3.0.4 IP, although you can connect from your machine which potentially has that IP.
You can try to create a 'root'#'%' user who will be granted to access regardless where you are connecting from.
I am frustrated seeing this error and not knowing the solution. I am trying to connect to a mysql db with a server url but it is giving my mysqlException(stacktrace below). The code works fine till here:
String dbUrl = "jdbc:mysql://server_url/db_name";
String driver = "com.mysql.jdbc.Driver";
Class.forName(driver).newInstance();
String user = "user";
String password = "password";
conn = DriverManager.getConnection(dbUrl,user,password);
This is the error I'm getting
java.sql.SQLException: null, message from server: "Host '172.23.251.154' is not allowed to connect to this MySQL server"
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1070)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
Is this because I'm using a different version of mysql-connector jar?
Please help me.
From Chapter 6. SQL Questions: How Do I Enable TCP Connections to MySQL?,
By default, MySQL won't allow ANY users access to any of the databases if they connect over a TCP connection. In order to permit the connection, you must create a entry in the user table of the mysql database (make sure you select the PASSWORD function to encrypt your password). In particular, the Host field needs to indicate which host(s) are permitted to connect. If you specify % (which I would not recommend), then a user would be able to connect from any host.
What about firewall on port 3306?
May be the user you are trying to access doesn't have enough privileges to access the database from the given server.
So try providing GRANTS to the user.
GRANT ALL PRIVILEGES ON database_name TO 'user'#'hostname' IDENTIFIED BY PASSWORD <password>;
FLUSH PRIVILEGES;
here hostname can be your host address "172.23.251.154". Dont forget to flush privileges and then try connecting the server.
If your MySql server is located on your host provider there is option in your control panel where you can set ip addresses from which you can connect to mysql server in your case 172.23.251.154 if this is your ip address
My MySQL server is installed in X.X.60.X and accessing it through JDBC from X.X.80.X . I can connect it through MySQL workbench but when connect through the program it shows the following error message.
java.sql.SQLException: Access denied for user 'user'#'X.X.80.X' (using password: NO).
I have given all privileges to 'user'#'X.X.80.X in the server.
Is the password for user 'user' set in you MySQL server? If yes, check your programm, is's not using password:(using password: NO)