Access denied for user 'xxx'#'xxxxxx' - mysql

I have a software which communicate with a remote mysql server. After updating the mysql on the remote host I get
2014-07-04 10:11:39.8750Access denied for user 'xxx'#'xxxxxx' (using password: YES)
When I try to connect to the remote mysql from the computer that running the software with the same user and pass there is no problem to connect.
Any ideas?

You have to configure the user ACL. Probably your user currently can access to db only from localhost. You have to grant access from the remote machine client IP.
Example:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'%'
for all privileges from all ip addresses. You can also replace the '%' with you remote machine IP

Related

Cannot call Remote MySQL database using SSH tunneling

I have two system where one system has the MySQL database (IP address is 192.168.0.149-running in centos) and the other has the web application (IP address 192.168.0.55-running in windows). I am calling the database from the web application remotely. I wanted to use ssh to connect with the database, so I use putty to do this.
First I run the putty and initiate the port forwarding from port 3535 to 192.168.0.149:3306.
I call from my application like this
orm.RegisterDataBase("default", "mysql", "john:john1#tcp(127.0.0.1:3535)/employee?
charset=utf8&parseTime=True")
I create a user in host MySQL database like this
mysql>create user john
mysql>GRANT CREATE,DELETE,SELECT,UPDATE ON employee.* TO 'rahul'#'192.168.0.55' IDENTIFIED
BY 'john1'
Now I run my web application. When I run it I'm getting the following error
[ORM]2017/03/01 16:18:57 register db Ping `default`, Error 1045: Access denied for user
'john'#'192.168.0.149' (using password: YES)
WORKING SCENARIOS
If I don't use the SSH and calling directly the database from the application then there is no problem for this user to access the employee database.
orm.RegisterDataBase("default", "mysql", "john:john1#tcp(192.168.0.149:3306)/employee?
charset=utf8&parseTime=True")
If I change the privilege condition like this then its working for ssh based remote database connection
sql>GRANT CREATE,DELETE,UPDATE,SELECT ON employee.* TO 'john'#'%' IDENTIFIED BY 'john1'
But I don't want to do this since it will accept the connection from all the system from the local network.I wanted to give the access to only 192.168.0.55.
Your credentials don't match.
You've granted access to 'rahul'#'192.168.0.55', but you're connecting as 'john'#'192.168.0.149'.
Try granting access to the user that's actually connecting:
GRANT CREATE,DELETE,SELECT,UPDATE ON employee.* TO 'john'#'192.168.0.149' IDENTIFIED BY 'john1'

MySQL external access for localhost

I need to connect a desktop application to a MySQL server. The website connect to the database 'localhost'. What would the the full path of the localhost be?
Using CentOS 6.5/apache/zpanel
The answer is probably so obvious that nobody has ever asked it before. But I rally can't figure it out. Here is the screenshot of what I have:
It's the IP address of the server which is running mysql (the same of the webserver, if you're connecting to it as localhost)
But many hosting companies disable remote MySQL by default, you may need to ask them to enabled it, or to whitelist the IP you are connecting from.
You have to grant access to the user you are using to connect from remote, on your case the root user so:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%'
IDENTIFIED BY 'password' WITH GRANT OPTION;
After this run this other command to refresh the new privileges
FLUSH PRIVILEGES;
The '%' is the option that you allow root to connect from anywhere. You can specify also an IP address.

Access denied for user 'user'#'host' (using password: YES)

I have a created user in my MySQL database:
CREATE USER 'user'#'host' IDENTIFIED BY 'password';
I have granted that user full privileges:
GRANT ALL ON *.* to 'user'#'host';
Echoing the grant:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'host' IDENTIFIED BY PASSWORD '*03FFC888F82E921D8CA360925A8F443CF326DE89'
I can connect from MySQL workbench using this login credential w/o any issues and execute queries. And it's running on the same machine the web application is running on. MySQL instance is running on another computer in the same local network.
However, when I try to use the same credentials from my web application running in Tomcat7 under Eclipse I receive the error. Please advise.
Note: As of last night, the web application was able to connect just fine. With nothing changing (that I am aware of - I am only one working on this), this morning I could not connect.
RESOLVED:
I added the user with grants using the IP address for the host for the local machine.
I am not sure what changed on the server, but now I am able to connect again.
Would someone possibly be able to explain this change, and with it why I am now required to use the IP address when previously the local host name was sufficient?
Make sure you are using the appropriate hostname, and you're accessing from that host, the user can't connect from another host.
To give permission you must put the password unencrypted.
Example
GRANT ALL PRIVILEGES ON test. * TO 'root' # 'localhost'
IDENTIFIED BY 'goodsecret';
Also must be the same password when you create the user.
Here How adding users to MySQL
Note: For more information on GRANT here is the documentation.
Hope this helps

Accessing MySQL with Toad via SSH

I'm giving Toad a try for use with my MySQL db, but I cannot seem to connect (Linux-based server with MySQL database) remotely using Toad. After entering the right credentials for both SSH login and the database login, I still get this:
'Access denied for user 'wlaprise'#'166.203.5.139' (using password: YES)'
I can however successfully login remotely using SSH and MYSQL commands directly from the command line using the same host and credentials, so I believe the credentials and firewall settings are not the problem. The username is the same for both SSH and the db (not the smartest, I know), so I even tried reversing the password entries in case I had the credentials switched. No difference.
I looked through Toad's 'Connection Properties' to see if it was encrypting my credentials somehow which could explain the 'Access denied' error, but didn't see anything.
This has to be basic, but I don't see what I'm missing? Ideas? Thanks.
When you are using shell command line , then you are connecting from localhost,
thus effective permissions are 'wlaprise'#'localhost'
What you can do is to grant permissions to same user, but from different location/IP:
GRANT ALL PRIVILEGES ON *.* TO 'wlaprise'#'166.203.5.139'
IDENTIFIED BY PASSWORD 'mypassword';
or
GRANT ALL PRIVILEGES ON *.* TO 'wlaprise'#'%'
IDENTIFIED BY PASSWORD 'mypassword';

Cannot connect to remote mysql through tomcat

I am able to connect to mysql through a gui workbench but when i try to connect with my applications datasource (which runs on tomcat) i get:
Access denied for user 'dbuser'#'192.168.100.231' (using password: YES)
i have tried all the options in the mysql reference guide but none worked.
any ideas?
You should grant access to remote machine. Connect to MySql as root and do this:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'IP' IDENTIFIED BY 'PASSWORD';
FLUSH PRIVILEGES;
Instead of IP you may use host you remote machine.