Hi guys I have a situation where I need that my Web Application, hosted in some other machine, access my local MySql Server Instance. My string connection looks like
mysql://<user>:<password>#<my_ip>:3306/<data_base_name>
However when I try to connect I am getting the error:
Can't connect to MySQL server on '1**.***.**.*7' (111)
Searching a little bit I discovered that it could be due the configuration of bind-address in my.conf file. However in MySql 5.7 there is no need to do that once, when I run the select below I get this:
show variables like 'bind%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| bind_address | * |
+---------------+-------+
Searching a little bit more, I found that it could be due the firewall blocking connection on port 3306. Then I created an inbound and outbound rule for that, but I'm still getting this error and I can perfectly connect to my MySql Server locally.
Besides, I've already seen these posts:
Can't connect to MySQL server error 111
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
How to allow remote connection to mysql
https://serverfault.com/questions/823877/mysql-connection-not-working-with-windows-firewall-on
However none of them solved my problem. Someone can help me out?
Related
I am new in XAMPP MySQL and PHPMyAdmin. The databases on these two platforms should be the same. However, similar to the problems shown in MySQL and PHPMyAdmin matching problem,
I found that SELECT ##hostname have the same results on XAMPP MySQL and PHPMyAdmin. However, the result for running SHOW databases on XAMPP MySQL is
*
information_schema |
mysql |
people |
performance_schema |
phpmyadmin |
test
*
whereas the result for running SHOW databases on PHPMyAdmin is
*
information_schema |
test
*
By the way, I am running XAMPP MySQL on Windows 10 PowerShell. Comments and ideas are appreciated.
Probably when you're connecting through phpMyAdmin, you're authenticating to MySQL as the anonymous user. Most MySQL installations come with an anonymous user which doesn't have many privileges at all, but can connect and see the databases you reference.
This could be because you're using a different username and password, or because the two methods are using a different connection type — to MySQL, a connection to over TCP/IP networking authenticates as a user with host "%" (or a specific IP address). A socket connection authenticates to the "localhost" host. Using host names of 127.0.0.1 (or any IP address/hostname) forces a TCP/IP connection; connecting to 'localhost' forces a socket connection.
So probably what's happening here is that you're using the phpMyAdmin default connection type of localhost and telling the command-line client to connect to 127.0.0.1, but you only have your user set for host '127.0.0.1' (or '%'). You can edit your phpMyAdmin configuration to tell it to connect to 127.0.0.1 instead, or duplicate the user#127.0.0.1 and give the new user the host 'localhost'. Either should get you in again if this is the cause.
I'm trying to use putty to create a tunnel to a MySQL DB and then use that tunnel to connect to the DB using workbench. When I start putty and check the logs I get the following error message 2015-10-15 17:55:13 Local port 3306 forwarding to192.100.1.199:3306 failed: Network error: Permission denied
But when I view the sql statement for the port for the mysql DB I get
SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
The thing is I can connect to 192.100.1.199 VM and the hostname for the DB is also 192.100.1.199. Does anyone why this might fail on permissions.
Sounds like you might already have something locally bound to port 3306. I suggest you use a different local port (say 5000) so you end up with
L5000 192.100.1.199:3306
Then connect via localhost:5000.
Were you able to directly use ssh, you would have seen an error message similar to
bind: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 3306
Could not request local forwarding.
which is probably a lot more informative than what you were getting out of PuTTY :)
ERROR 2003 (HY000): Can't connect to MySQL server on 'xx.xx.xx.xx.' (60)
I'm getting this error when trying to connect to this server remotely.
I recently hard rebooted my server and I'm guessing I haven't started something I need to.
I'm running Ubuntu 14.10
Mysql is up and running. All the sites that use this db are up and running. I can also log into the server and admin the db. But I prefer using a mysql client (navicat) for admin.
Prior to this reboot I was able to connect to this server remotely (navicat) for administration.
I have the appropriate entries in the mysql.user table (as I've said, I was able to connect remotely at one point)
my.cnf file:
#skip-external-locking
#bind-address = 0.0.0.0
Any clue as to what might be preventing connection
This error tells you that client can not reach the server, not that server is not operational. Maybe the address has changed (dhcp?), or port is blocked...
I'm trying to connect to MySQL Server installed on a machine with Windows OS. The connection is remote to type, but not on a local network (LAN). A pc (also with windows) in my house and the other in college. For three days I have been reading the documentation on the MySQL website and other sources, such as other SO questions but got no success. Below all my settings. Also wanted to know if anyone else is having the same problem. No need to mention the issue of security (SSH, token, pipe, etc), I do this using free software just to show the lack of security or bad pratice, just to educational purposes.
All ports are open on the router, and it is configured correctly, firewall off;
Firewall turned off on both computers (client / provider) and all the doors open;
The two computers have Win7 Ultimate 64x;
The service of MySQL 5.5.37 Community Server is running on the server computer;
The client tries to connect by HeidiSQL 8.3 (TCP/IP) (64x);
The SQL GRANT ALL PRIVILEGES ON * TO 'USERNAME' # 'IP' IDENTIFIED BY 'PASSWORD';. FLUSH PRIVILEGES;, has already been tested.
The file "my.ini" was checked the "bind-address" in the Win version does not have this entry.
The variable "skip_external_locking" was set to "OFF";
Services such as FTP and HTTP function normally.
Any tips on this question were tested.
Misses something important?
The error:
ERROR 2003 (HY000): Can't connect to MySQL server on 123.123.123.123 (10061)
mysql> select host,user,password from mysql.user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| % | root | *blablablablabla |
| 127.0.0.1 | root | *balblablalbalbalb |
| ::1 | root | |
| localhost | | |
+-----------+------+-------------------------------------------+
4 rows in set (0.00 sec)
I finally got it! So what I did:
Fully Uninstall MySQL;
I installed the latest version of MySQL 5.6;
I did all the steps in the question above;
I did all the tests of ports, and everything working;
I tried to connect as root to the host '%', it did not work;
I created a new User with all privileges of the root and host '%', then I could connect.
When did MySQL 5, all the doors were open and still not connected, even putting exceptions in the firewall for the ports and for the mysql program. But when I installed MySQL 6 it automatically created the exception to the windows firewall as below:
Were equal to MySQL5.This was not an answer. In fact Windows the best way to prevent such inconvenience is always using the latest version of MySQL. So if someone did all the steps I listed in the question and did not work, completely uninstall MySQL and install the latest version may solve the problem, just be careful with your database.
When I am at the office, MySQL runs on a specific server which is called "mysqldev". In my /etc/hosts file I have set "mysqldev" to match the IP of this server. So far, so good. However, when I am out of the office using my laptop, I want to use my local MySQL database, as I clone specific databases there and have no internet to connect to the office database. I do not want to change my scripts, but rather my laptop configuration. So on my laptop I have set in /etc/hosts:
127.0.0.1 localhost mysqldev
However, for some reason this does not work as expected. If I log in to MySQL using the server at localhost, all good. But when I try to log in on the mysqldev server (same IP as localhost), I get the error:
Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] Connection refused (trying to connect via tcp://mysqldev:3306)
(this is using PHP, but using the command line it is the same error)
The users that are set up on the system have specific permission to log in on this server:
CREATE USER 'test'#'mysqldev' IDENTIFIED BY '123';
GRANT ALL PRIVILEGES ON testdb.* TO 'test'#'mysqldev';
I have also turned off the firewall to test, and it does not make a difference. What could it be?
The MySQL client library tries to guess how to connect to your database. When you give localhost as the hostname, it assumes, that you're using a local socket (search your computer for a file named mysql.sock, probably under /var/lib/mysql or /usr/local/mysql/.
However, when you use anything else, like an ip address, a different hostname, or, in your case, mysqldev, it tries to connect to the host via tcp. From the error message, it seems as if your local mysql server is not listening on the tcp port 3306 (the mysql default)
Check, if your my.cnf (probably /etc/my.cnf or /etc/mysql/my.cnf) allows the use of tcp. If you find a line like
skip-networking
comment it out:
#skip-networking
and restart the server. Then try again to connect.
To find out, where your socket is, connect through localhost and issue the following command:
mysql> show global variables like '%socket%';
+---------------+-----------------------------+
| Variable_name | Value |
+---------------+-----------------------------+
| socket | /var/run/mysqld/mysqld.sock |
+---------------+-----------------------------+
If you are using MAMP Pro and are running into issues, you can simple uncheck the box labeled "Allow local access only" within the MySQL Server settings.