As the screenshots show, I have the accounts setup to allow remote connections but as shown in the second screenshot I still cannot connect remotely.
I use for testing in the virtual machine (Ubuntu 16.04), for me, I fixed the error changing the file 50-server.cnf.
My server is Ubuntu, so changing the file below:
50-server.cnf
The path of this file:
/etc/mysql/mariadb.conf.d
PS: Create a backup of the file before the change.
Only change in file the bind-address 127.0.0.0 to bind-address 0.0.0.0
After this restart service and try again.
Regarding that user, need to allow for external connections.
I hope that this info helps you.
Mysql by default binds to 0.0.0.0 which is all interfaces on your system. Which means you can already connect from another computer. The issue is perhaps permissions. You can enable remote connections by running the following command:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'192.168.%' IDENTIFIED BY '' WITH GRANT OPTION;
MariaDB packages bind MariaDB to 127.0.0.1 (the loopback IP address) by default as a security measure using the bind-address configuration directive. Old MySQL packages sometimes disabled TCP/IP networking altogether using the skip-networking directive.
Steps to allow remote connections are provided in the MariaDB Knowledge Base at https://mariadb.com/kb/en/mariadb/configuring-mariadb-for-remote-client-access/
Related
I am experiencing some difficulties to configure MySQL Server and allow remote connections. I am currently using Ubuntu Server 16.04 and the latest MySQL version. This is a Virtual Private Server (VPS) from VpsDime (I apologize if this is not relevant). Everything i have done has been accomplished by SSH protocol using the root user.
This is the error Workbench throws me when I try to connect to MySQL:
Your connection attempt failed for user 'globalAdmin' from your host server at <IP>:3306:
Can't connect to MySQL server on '<ServerIP>' (10060).
I have been following and reading tutorials to configure it at this point. So, the relevant things i have done for this are:
Install the latest version of MySQL
Create a user granting full privileges for local and outsiders by this way:
CREATE USER 'myuser'#'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'#'%' IDENTIFIED BY 'mypass';
GRANT ALL ON *.* TO 'myuser'#'localhost';
GRANT ALL ON *.* TO 'myuser'#'%';
I modified the MySQL configuration file /etc/mysql/mysql.conf.d/mysqld.cnf using nano. The change i made was replacing this:
bind-address = 127.0.0.1
For this:
bind-address = 0.0.0.0
This is to allow remote connections, this was suppose to be done in my.cnf file, but i modified another file based on the first answer here: https://askubuntu.com/questions/699903/why-is-etc-mysql-my-cnf-empty
Also i added the following two lines in my file.
[mysqld]
bind-address = 0.0.0.0
Finally, using UFW I am allowing the port 3306 and 3306/tcp. Using the command sudo ufw status I am getting this (i am showing only the relevant):
3306 (v6) ALLOW Anywhere (v6)
3306/tcp (v6) ALLOW Anywhere (v6)
Which as far I know is all I need to connect remotely.
The way I am connecting to MysQL server is by MySQLWorkbench for Windows, Connection Method: Standard(TCP/IP) using my server ip address, default port (3306), the "globaAdmin" user I created as mentioned before without Schema.
---The following MAY NOT be relevant---
Im having the same issue for MongoDB, it is funny because I also installed MS SQL Server 2017 and the only thing i did to connect remotely was open ports for it with the UFW tool.
I deploy a mysql service on my company remote develop CentOS machine, I'm sure the service is turn on, and it can be access from an other reomte linux machine.
However, I can't connect it from my own Windows PC. I tried mysql workbench client and HeidiSQL client, both failed. I can ping through the remote IP address. I have tried anything I can found on google. Like
add bind-address = 127.0.0.1 to cnf file, and comment out the skip-networking.
I also tried the answer on another question Can't connect to remote server using MySQL Workbench on mac, which allow all machine can access to the service.
But my PC still can't connect to it, which report code 10060 error. So what should I do?
That bind-address = 127.0.0.1 config option means that your mysql server only accepts connections from the localhost, which is your actual CentOS machine. Make sure to set bind-address = 0.0.0.0.
Also, make sure that:
you have connectivity from your windows machine to the CentOS one
no firewall blocks the external connections to the local mysql port
Regarding potential security concerns from opening your mysql instance to the whole internet - first make it work, then make it better
I had the same issue here man,and i discovered that we need to create a user that isnt the root user. I my case, i don't know why yet, the issue was that.
The solution
Steps:
1 - Check the firewall (create a rule for port 3306 or disable it).
2 - Comment the line # bind-address=0.0.0.0 at [mysqld] config optin in C:\ProgramData\MySQL\MySQL Server 5.7\my.ini
3 - Create the user to remote access:
mysql> CREATE USER 'net'#'%' IDENTIFIED BY '123';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'net'#'%' WITH GRANT OPTION;
In my case, solved.
I have mysql installed in an instance of google compute engine. I am able to connect to it via the shell however I want to use the MySQL workbench.
Is it possible to connect to it? I cant seem to make a connection.
Any help is appreciated,
Thanks!
Not sure if your shell is run local on host via ssh, so it's just a guess that your mysql Server is just accepting connections from localhost.
To change this open your my.cnf File (on Debian Systems saved in /etc/mysql/my.cnf) and comment the folloing Line:
change:
bind-address =127.0.0.1
to:
#bind-address =127.0.0.1
Be sure also to allow root connection from outside, modifying MySQL user table :
GRANT ALL PRIVILEGES ON . TO 'root'#'%' IDENTIFIED BY 'password';
SOehl's answer can be correct, however I did not comment. Instead i changed it to bind-address 0.0.0.0.
We have a MySQL server in one of the remote Virtual Machine (Windows Server 2008). Till yesterday we were able to connect to the MySQL server, with the help of workbench installed in our local machine.
Yesterday there was a restart to the machine which has the Virtual Machine installed. After that we are unable to connect to MYSQL. Though I can ping and remote connect this particular VM. I can even execute the queries inside the workbench installed in the VM.
I am not too good at networking or security related stuffs. Please help me to solve this issue.
Error :
Your connection attempt failed for user 'root' from your host to server at ABC:3306: Can't connect to MySQL server on 'ABC' (10060)
Really this could be a magnitude of possible reasons, hopefully this is a start:
Check basic network
From the MySQL virtual machine open up a command prompt and type IPCONFIG /ALL. This will show you all the IP addresses bound to different network adapters.
Check that the IP address you're connected to is listed there, the virtual machine might have got a new IP from DHCP rather than having a static IP after its restart.
Hostname vs IP
You should check the hostname resolution, from your quoted error it would suggest you are you are connecting to a hostname rather than a server IP. Check your machine can resolve to the hostname using the correct IP address - it could also be worth changing the hostname for the actual IP of the server in the connection string.
MySQL config file
You've said you're running MySQL on Windows, it was customary to rename the my.cnf to my.ini. The configuration file for older versions of MySQL previous to 4.1.5 was usually stored in either c:\my.ini or c:\windows\my.ini. For versions after this the default location is the installation directory usually %PROGRAMDATA%\MySQL\MySQL Server xxx.
When you have located the configuration file please open it on Notepad (or similar text editor), locate the [mysqld] section and make sure that port= the port you're trying to connect to and bind-address= the IP address you're trying to connect to.
Server ports
From the MySQL virtual server open a command prompt and type netstat –ano, this will show you a list of processes and what IP's / ports they are listening on. The MySQL server should be listed here and should be listening on the same port and IP as the config file defines.
Windows firewall
You should have a firewall rule to allow MySQL, the following will add one on the default port of 3306
netsh advfirewall firewall add rule name="MySQL Server" action=allow protocol=TCP dir=in localport=3306
Identify if this is machine specific
You could setup the MySQL Workbench application on another workstation and try to connect to identify if this is a global problem or just one related to your specific workstation.
mysql administrator of your database should allow remote connection to the mysql server.
change this in my.cnf:
bind-address = 127.0.0.1 # this shoul be your mysql server ip
and comment this:
# skip-networking
Chances are that your configuration was set up for an IP that has changed. By default, mysql won't let you connect from remote hosts unless you explicitly give permissions for a specific user on a specific schema or a group of schemas, for example if you did something like this:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Maybe what you actually did was to set the grant onto your own IP address, that is the address of your local machine, and if your local machine (not the remote server) has changed it's IP address, then mysql will not let you connect unless you have the "1.2.3.4" IP address which obviously you don't have anymore if you have a dynamic IP address (common with DSL/Cable connections)
So connect through SSH or Telnet or whatever you use to your windows server and go to mysql as root and do this:
SELECT * from information_schema.user_privileges;
That will show you the grants on all users and how they are allowed to connect. If you don't see your local IP Address listed there or a wildcard (which would allow you to connect from any remote machine to the server) then you have to set it up like this:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Where USERNAME of course is your user. See that after the on there is a wildcard / dot /wildcard that means you want that user to be able to connect to any schema (database, for mysql) from any user from any network. But I'd recommend that you only do the grant for the user for the specific schema you need to connect to.
Then after that, if you actually had the right information and still can't connect than use a portscanner like nmap or something like that to do a port scan and see if mysql is:
Open and listening to external network
Running on the port that you actually want to connect through
If 1 is true, then check 2 because maybe there is a misconfiguration of the port. But if any of these 2 points do work then it sounds definitely not like a network configuration but a user setting or something else.
GRANT ALL ON *.* to user#'%' IDENTIFIED BY 'password';
this command should do the trick for all users #Gustavo Rubio has already given the proper explanation.
To ensure what ports are open run cmd in the virtual machine and type.
netstat -a
TCP 127.0.0.1:3360 Hostname:3360 LISTENING
The my.cnf is located Mysql-install-path\MySQL\MySQL Server xxx make sure you backup original before changing
Can't connect to [local] MySQL server
Testing The MySQL Server Installation on Microsoft Windows
MySQL Workbench: Manage MySQL on Windows Servers the Windows way
For the first time you need to test and make sure your connection to mysql is not blocked by the firewall.
To disable the firewall on each host in your cluster, perform the following steps on each host.
1. Save the existing iptables rule set.
iptables-save > /root/firewall.rules
2. Disable iptables.
For RHEL, CentOS, Oracle, and Debian:
chkconfig iptables off
and
/etc/init.d/iptables stop
For SLES:
chkconfig SuSEfirewall2_setup off
and
rcSuSEfirewall2 stop
For Ubuntu:
service ufw stop
https://www.cloudera.com/documentation/enterprise/5-7-x/topics/install_cdh_disable_iptables.html
Depends on your setup, but if you're using cPanel just go to RemoteMYSQL and enter your host. You can also use a wildcard. Below worked for me when I was getting the error
"Could not connect to DB server '' as user ''. port : Host '' is not
allowed to connect to this MySQL server"
On MySQL v5.6 this may be the case.
When another server communicate by advertising its hostname instead of IP address, the resolution might fails (because your user is using IP address instead of hostname for example).
So, you need to disable the following,
skip-host-cache
skip-name-resolve
Or maybe create the user with appropriate hostname (instead of IP address). You may find the hostname when establishing the connection to the remote MySQL.
I have a MySQL Server 5.5.32 running on Ubuntu 12.04. Ubuntu is being run on VM. Host platform is Windows 7. How can I connect with the Ubuntu's MySQL from Windows?
I have done the following so far:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Running a show grant for root; displays this:
+-------------------------------------------------------------+
| Grants for root#% |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' WITH GRANT OPTION |
+-------------------------------------------------------------+
But when I try to connect to this server from SQLYog running on Windows, I get an error Error 2003 Cannot connect to mysql server on '192.168.xxx.xxx'.
The IP being feed to SQLYog, I got it from ifconfig. Supplied the inet addr.
inet addr:192.168.226.xxx Bcast:192.168.226.yyy
Is the address being used is incorrect or are these grant issues? Please advice.
You problem is that (probably) your mysql is bind to 127.0.0.1 instead of 0.0.0.0.
You should change bind in /etc/mysql/my.cnf to 0.0.0.0
bind-address = 0.0.0.0
And then restart mysql of course.
In newer versions of MySQL, instead of skip-networking the default is now to listen only on localhost
bind-address = 127.0.0.1
So you need to add your machine IP to here or simply comment it out if you are not worry about security concerns.
The error message Error No. 2003: Can't connect to MySQL server on 'localhost' (or some other host)
simply means that connection is not possible for one of the following (or similar) reasons:
There is no MySQL server running at the specified host
Connection to the MySQL server is not allowed using TCP-IP. Check the 'skip-networking' setting in the MySQL configuration file (my.ini on Windows, my.cnf on Unix/Linux). It shall be commented out like '#skip-networking'. If it is not commented out, then do it and restart the MySQL server for the change to take effect. SQLyog needs to connect using TCP-IP.
Some networking issue prevents connection. It could be a network malconfiguration or a firewall issue. We have experienced sometimes that some firewalls is blocking TCP-IP connections even if it claims to be disabled. Most often it will help to uninstall and reinstall the firewall.
When trying to connect to a MySQL server at an ISP this error message often indicates that direct connection to MySQL has been blocked. You must then use HTTP-tunneling or SSH-tunneling to connect.
I think the problem is with the Network Adapter settings in your VM settings
Do like this in your VM settings.
VM Settings -> Network Adapter Settings -> Select Bridged
The VM will connect to the physical network when the network connection is on bridged mode.
Try to ping the VM host in your windows machine after changing the network connection to bridged.
If the VM is pinging in your windows machine then it will work.
Error No. 2003: Can't connect to MySQL server on '192.168.x.x'
simply means that connection is not possible for one of the following (or similar) reasons:
There is no MySQL server running at the specified host
Connection to the MySQL server is not allowed using TCP-IP. Check the 'skip-networking' setting in the MySQL configuration file (my.ini on Windows, my.cnf on Unix/Linux). It shall be commented out like '#skip-networking'. If it is not commented out, then do it and restart the MySQL server for the change to take effect. SQLyog needs to connect using TCP-IP.
Make sure that you are able to connect to MySQL port using telnet
C:\telnet hostname/IP_address port