I've set up a MySQL server through GCS VMs, Set up all of the required users, etc however I can't remotely connect.
I've opened the ports through firewall, given all the required permissions, made sure the server is running and just about every other method I've found so far. I checked the my.ini file (Using 8.0 on Windows 2012 R2) and found no 'bind-address' value or similar in the file.
I've assigned a static IP, ran:
"CREATE USER 'root'#'%' identified by 'password'; GRANT ALL PRIVILEGES ON *.* to 'root'#'$';"
and I'm getting the error
Cannot connect to database server...
unable to connect to...
any help to do with remote connection appreciated :)
Related
I've currently set up a staging area for my app in Digital Ocean with LAMP stack. The Framework for my app is Laravel 5.5 and Vue 2x.
In development, I've been using remote MySQL and had no issues with the connection error. However, when I moved it to the staging env, it is giving me access denied error. When I looked at it closely to the error log, Access denied is for username#[digital-ocean-droplet-ip], whereas I have properly configured the MySQL credentials to the remote host IP under laravel's config/database file.
So, I am doubtful if I have to do any configuration under Apache to allow any external MySQL connection? I forgot the cmd but I did allow sfw firewall allow to any port 3306 to the remote server IP address in Apache.
Any help is appreciated.
Thanks!
MySQL by default does not create an user with access from remote connections.
First you need to create an user on database that allows connection from outside (%) or a specific IP
CREATE USER 'newuser'#'%' IDENTIFIED BY 'password';
Than give him privileges
GRANT ALL PRIVILEGES ON *.* TO 'newuser'#'%';
The *s could be replaced by your database and table name respectively
You might also check if in your mysql configuration(/etc/mysql/mysql.conf.d/mysqld.cnf in my case) has this line uncommented
bind-address = 127.0.0.1
Change the ip if necessary
restart mysql and apache
sudo service apache2 restart
sudo service mysql restart
Than update the user and password at your .env file and try again!
I've looked in so many areas to try to fix this problem and I can't seem to find a solution. Im running ubuntu linux with the latest mysql and phpmyadmin installation. I found that connecting to the database locally works but if I try to connect remotely it keeps denying the connections. The only way I can login to phpmyadmin is if I put the ip address in the bar, connecting via the web address will not work.
Are you trying to connect to MySQL remotely or PHPMyAdmin remotely?
If you are trying to access MySQL remotely, you need to do the following:
Edit the bind-address variable in /etc/my.cnf, to 0.0.0.0 or the IP address of your server
Make sure your MySQL user has permissions from remote hosts, do this using:
CREATE USER 'myuser'#'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'#'%' IDENTIFIED BY 'mypass';
Then:
GRANT ALL ON . TO 'myuser'#'localhost';
GRANT ALL ON . TO 'myuser'#'%';
Then go ahead and restart the mysql instance on your server. This also assumes you have set IP tables up to allow port 3306 TCP incoming to your server.
I am not so into DB and I have the following problem.
I have installed a MySql 5.7.17 on a remote Ubuntu 16.04 server and I have to connect to this server from a client installed on my laptop.
So The first thing that I have done is that I have changed the bind-address directive values (into the /etc/mysql/mysql.conf.d/mysqld.cnf file) from:
Bind-address=127.0.0.1
to:
bind-address = 0.0.0.0
to allow also external connection.
The problem is that when I try to connect from my client (installed on my laptop) I obtain this error:
Host 'XXX.YYY.ZZ.JJ' is not allowed to connect to this MySQL server
(where **XXX.YYY.ZZ.JJ* is my laptop IP address).
From what I have understood I also have to give to the mysql user w the db permissions to connect from any host and not just from localhost.
I think that it should be something related to the grant: https://dev.mysql.com/doc/refman/5.5/en/grant.html
What exactly have I to do? I think that I have to access to MySql from my server shell (via SSH) and then perform a query that grant some privileges to the root user (the MySql user) to allow to access from outside.
But I don't know what exactly I have to do. How can I allow this external connection for the roo user?
As you mentioned, you need to login to mysql server with root access and then run following command on mysql prompt
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_db_user_name'#'%' IDENTIFIED BY 'newpassword';
you can also specify a specific IP instead of %
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_db_user_name'#'your_IP_here' IDENTIFIED BY 'newpassword';
you can also specify a for all databases
GRANT ALL PRIVILEGES ON *.* TO 'your_db_user_name'#'your_IP_here' IDENTIFIED BY 'newpassword';
I have a MYSQL server running on my Windows 7 and I need to access it from a Debian VM but when I try I get this error :
ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (110)
I checked in my.ini and there is no sign of "bind-address" parameter around so I just can't figure out where the error is.. I can perfectly manage it locally from my Windows. My company is using a proxy but as my VM is on my machine it shouldn't block anything there..
Thanks for your help !
You need to change user host adress as * or given xxx.xxx.xxx.xxx IP.
Look at here: grant remote access of MySQL database from any IP address
To access MySQL from outside. you should enable MySQL remote access .
1- Comment out following lines in Mysql Config(my.cnf/my.ini(for windows))
#bind-address= 127.0.0.1 (if not exist add it and then comment out)
#skip-networking
2- Save the file and restart Mysql server
3- Update GRANT privilege
By default, mysql username and password you are using is allowed to access mysql-server locally. So need to update privilege.
Run following query to update privilege
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Change the 'USERNAME' to your Database user and 'PASSWORD' to User Password
You should check that:
"bind-address = 0.0.0.0" is present in your my.cnf
The user your are using has remote access (not just 'locahost')
Check that MySQL port (usually 3306) is opened if you have a firewall running
I would really advice to create a specific user for remote access with limited rights.
Finally I uninstalled everything and trieed again and it worked so now I close this ticket for good.
Thanks to those who have tried to help me !
Ive looked all over for this one... Ive tried creating a new user, granting full priv on any ip, verified that they are there, restarted mysql server/ the server host, tried different clients on different machines. I really can't think of anything else to try. So far, I used this on root:GRANT ALL ON my_database.* TO my_user#'%' IDENTIFIED BY 'some_password'; Then checked show grants for 'root'#'%' which shows GRANT ALL PRIVILEGES ON . TO 'root'#'%' IDENTIFIED BY PASSWORD '*ACE0FA0C29A21972F42BD2E7805A0D01C7126EC3' WITH GRANT OPTION
Always getting the same error,
ERROR 1130 (HY000): Host '192.168.xxx.xxx' is not allowed to connect to this MySQL
server
I also checked the firewall and that does not appear to be an issue. All the hosts are on the same local network. I have tried connecting via a public domain name and also direct local IP.
The server is on Windows 7 and I have tried connecting with clients on debian and OSX. I have no idea what is wrong, any ideas?