I'm runnning MySQL 5.6 on DB server and trying to conect from application server. (app1.example.org)
On DB server, user#app1.example.org is registered as user.
I logged in app1.example.org (CentOS 6), and tried to connect DB server.
[mylocalmachine]$ ssh phanect#app1.example.org
...
[app1.example.org]$ mysql -u user -p -h 123.456.789.012
Enter password:
ERROR 1045 (28000): Access denied for user 'user'#'111.222.333.444' (using password: YES)
111.222.333.444 is associated to app1.example.org in DNS.
When I add a user user#111.222.333.444 to MySQL and try above again, I can successfully connect to MySQL. But I don't want to do this.
IP address is a little bit hard to remember, and it sometimes changes because I'm using Google Compute Engine for app server.
I want to add only user(s) with host specified in FQDN. Is it possible?
I'm using Google Cloud SQL as DB server, BTW.
You can make it open ,and use it through username and password of your db,else you just make your compute engine IP static ,so that it won't change .
Related
I'm trying to establish a connection to a MySQL server on a remote host. Both machines are running RH 7.5 and MySQL 5.7.
I can connect to the server as a root user. I did that, and used it to set up a secondary user like this:
CREATE USER 'foo'#'client-ip-address' identified by 'my-password';
and then
GRANT ALL PRIVILEGES ON my-db.* to 'foo'#'client-ip-addres';
That all went fine. But to my surprise, when I tried to connect using this new user, I got an error I wasn't used to:
$ mysql -u foo -h server-ip-address -pmy-password my-db
Access denied for user 'foo'#'some-hostname-not-an-ip.com' (using password: YES)
I know the IP address of the client (where I'm connecting from), which is why I set up the user with that value in the "host" column on the server. But the client is obviously trying to establish a connection using a value for "host" that is not the IP address. Instead it's some hostname, and not an IP address at all.
Where is this value coming from? How does mysql determine its own host when it tries to connect to a remote server? In the past I've only ever seen it use the machine's own IP address.
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'
I have a mysql database running on a VPS. I can ssh into the host and connect to mysql with no problems. I cannot connect to mysql remotely from my desktop. I have performed the following:
opened port 3306 on the firewall
added my local IP to the remote IPs accepted by mysql. This was done via CPanel
executed
GRANT ALL ON dbname.* TO username#'x.x.x.x' IDENTIFIED BY 'PASSWORD'
to tell mysql to let me connect from the specified address.
I execute the following from the command line on my desktop:
mysql -h x.x.x.x -u username -p
I get a password prompt which indicates I am past the firewall and mysql is responding. When I supply the password, it denies access:
ERROR 1045 (28000): Access denied for user 'username'#'x.x.x.x' (using password: YES)
Have I missed something?
The answer was given in the comments, so I will repeat it here to properly close the thread. alvits suspected that the remote user had not been created. It had been created but his comment prompted me to clean up the user table.
I deleted all remote users including loads that had been created by CPanel or migrated from another host. I then started from scratch doing create user and grant all and it works now.
Thanks!
I'm trying to get access to my mysql DB from linux RedHat console. All the tome I'm getting:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES).
Obviously it seems that the root password is incorrect, but it isn't, because I can connect without no problems from the Website. All the PHP configuration files from several installed frameworks are using the same configuration parameters.
I'm using the following to connect from console:
mysql -u root -p
When the console prompts the password I can't get access.
Any idea?
Thank you very much in advance.
Jordi
Did you try resetting the password for root#localhost? Might be fastest way to solve this.
check if php connects from the same machine/ip and if mysql binds address 0.0.0.0.
dev.mysql.com/doc/refman/5.1/en/… : For example, if you bind to 0.0.0.0, you can connect to the server using all existing accounts. But if you bind to 127.0.0.1, the server accepts connections only on that address. In this case, first make sure that the 'root'#'127.0.0.1' account is present in the mysql.user table so that you can still
When I try to connect to a remote mysql database I receive an error saying I was unable to log into my router's mysql database.
tom#main:~$ mysql -u appleton -p -h 85.17.xxx.xx
Enter password:
ERROR 1045 (28000): Access denied for user 'appleton'#'85.210.169.xxx' (using password: NO)
Even though I am specifying my IP (85.17.xxx.xx) in the argv the error message is showing my Router's external IP (85.210.169.xxx)
I discovered this whilst using DBI->connect in perl.
Am I missing something obvious?
'appleton'#'85.210.169.xxx' is supposed to show your host, not the database's host. It's your full identifier (username#host) for mysql to determine if you are allowed to connect. Do you have sufficient rights to connect to the database from your IP? Access can be granted to users so that they can only connect from localhost for example.
MySQL Docs on Users