MySQL does not work on localhost without Local Area Connection - mysql

I use WampServer (Apache, PHP, MySQL) and have no problems when some kind of network adapter(wireless or lan) is connected (i.e. Local Area Connection has status connected) even if i am not connected to the internet (for example when i am connected to the router but that is not connected to the internet).
When there is no network connection, I get a php error like MySQL could not connect to 127.0.0.1 on port 3306.
Interestingly, telnet 127.0.0.1 3306 says that it could not connect to the port, even when the server and MySQL are running fine (i.e. when some kind of local area connection is connected).
So I turned off all kinds of firewall (antivirus and Windows) but still no difference in anything. And that is why this issue is quite puzzling.
Things I have already tried (will update this list along the way):
The skip-networking directive in my.ini.

You could modify your MySQL server and client configuration to connect to one another using a named pipe instead of a TCP/IP loopback connection. That way, the current state of the network connection should have less impact.
To do so, start the server with --enable-named-pipe or the corresponding config file setting, and execute the client with --pipe or --protocol=PIPE. Similar configurations should be available for your PHP connector as well. It may depend on which library you use there, and whether or not it will take the mentioned configuration settings from the my.ini file (settings without leading -- there).

Related

Cannot connect remotely to my SQL server remotely

Well, first off, I am no programmer. I am a medstudent with decent computer knowledge, and that has done this at least one time before in his home network.
Now, i am doing some research at the hospital, and for my database i want to use mysql, running a server on a local network computer and being able to connect to it from laptops over wi-fi to work on the database.
So i download mysql installe, run it, and i connect via localhost perfectly well with the root acc or the set up accounts i will use. I do bind-address to change its ip to the computers IP on the network, and i can connect again with root and with my accounts perfectly well on the machine the same server is on, using xx.xx.xx.xx + port to connect, with root and all other users.
however, using workbench on a laptop connected to the local network, I cannot connect with any user, it always gives error 10060.
--Firewall is off
--All AV software is off
--accounts are set up correctly to allow connection from any host
--client PC can ping server PC
--Netstat -anob shows mysqld.exe listening on the port i need it to be listening
The network here does block connections, but the port im using is open due to the fact it is used for another server type application that as very little to no traffic, so i just grabbed the opened ports for that application as they showed up in netstat and configured te server to use one of those ports.
How can i make sure the server PC is open at those ports?
THe client im trying to connect with is either the mysql workbench or heidisql.
Neither can connect, however i have succesfully used heidi before to connect to a database I have in DB4free.net. I cannot use that at the hospital, because the network shuts off the default port for mysql which is what db4free.net uses.
Any ideas why i cant connect to that PC?
mySQL often does not come configured for remote connections by default. The port may be open, but if mySQL isn't listening or is set to reject all remote connections, you won't be able to connect.
Check the documentation for your version of mySQL to find out how to modify your mySQL server's configuration to allow remote connections.

How to fix 'Can not connect to MySQL server' error?

First of all I apologize for my English is not perfect.
I'm trying to connect to mysql database remotely.
I have already done the basic steps such as, for example, comment the bind address in my.cnf.
I gave permissions to the appropriate users in MySQL.
I tried with my friend to do it connect to the database, and it worked but we were in the same room with the same router.
Now I'm home and I tried to connect my friend, but I always get error:
ERROR 2003 (HY000): Can not connect to MySQL server ....
Maybe it's a problem of my home router? I can not even do the telnet.
P.S. I've also taken steps to set the firewall.
Some reasons for that,
mysqld is not running on the local host. Check your operating
system's process list to ensure the mysqld process is present.
You're running a MySQL server on Windows with many TCP/IP connections
to it. If you're experiencing that quite often your clients get that
error, you can find a workaround here: Section B.5.2.2.1, “Connection
to MySQL Server Failing on Windows”.
Check whether the server is running on that host by executing telnet
some_host 3306 and pressing the Enter key a couple of times. (3306 is
the default MySQL port number. Change the value if your server is
listening to a different port.) If there is a MySQL server running
and listening to the port, you should get a response that includes
the server's version number. If you get an error such as telnet:
Unable to connect to remote host: Connection refused, then there is
no server running on the given port.
Look at this mySQL full documentation, it will be helpful.

Unable to connect to MYSQL on a remote computer

I am working on windows and having a remote desktop connection of another machine. I am trying to connect to the mysql running on the remote machine through my MySql workbench, installed on my machine.
When I specify the details to connect to mysql i.e.
IP- a.b.c.d
port-3306
username=root
password=
But everytime it shows me an error saying-
Your connection attempt to connect to user='root'failed from your host to server at a.b.c.d:3306
Is it possible that I can connect to mysql on a different machine?
Certainly that is possible, mysql is a network transparent service. However obviously the normal access authorization rules apply.
do you have network access to the mysql port, this might be blocked by a firewall. You can check that by using telnet ip-address-of-server 3306. Does the server answer or do you get a timeout or are blocked? (the answer would look cryptic, soomething like 5.5.33-MariaDB[*[n7p~g!�iXccI$r9``Y{$mysql_native_password or similar )
the mysql server can be configured to not listen to remote connections. This can add security to the setup, but would obviously block any remote connection attempts. You will have to check the configuration files of mysql for that.
mysql itself implements an authorization level. So check if that 'root' user actually is allowed to connect from the outside. Those authorizations are stored in the internal "mysql" database.
Also it is not clear from the question what your network topology is: is the mysql server running on that system you have a "remote connection" to? Is the mysql-workbench running on that remote system or on your local system? This might affect the ip address you have to use inside the workbench.

Passenger not reaching MySql

I have Nginx+Passenger+Rails3.
Passenger throws the following error:
Can't connect to MySQL server on '184.169.131.xxx' (111) (Mysql2::Error)
I am able to connect to MySql using mysql command. I think that the user that is running Passenger doesnt have the permissions.
I want to know: How to determine which user is running passenger and how to give permissions to access mysql.
Thanks
If it can't connect, it's likely that either:
Your MySQL process is bound to 127.0.0.1 and can't accept connections from remote machines.
Your firewall has blocked port 3306.
Are you certain that mysql is connecting to the same remote? You might be running a local server instead that allows access with the default configuration.
As a note, opening up 3306 to the general internet is a bad idea, so you will want to be very selective in how you do this. The best practice is to use private IPs whenever possible, like 10.x.x.x, 172.16.x.x or 192.168.x.x. There are a number of reserved blocks which can be used safely, but these cannot be routed outside your local network.
You should also check that whatever config/database.yml settings you have defined are the same you're using with the mysql command-line tool. Passenger is not treated as a special case.

OperationalError, Django Cannot Connect to MySQL Database

I am working a Django tutorial and I want to connect my project to a MySQL database. I did everything as told by the djangoproject tutorial to connect to database. When running python manage.py syncdb , however, I got the
following error:
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
What seems problematic? I have XAMMP downloaded and I have created databases through XAMMP before but I don't know how
that affects the connection with Django.
Thanks.
Actually under the settings.py, I set HOST to "127.0.0.1" and PORT to 3306, filled out the rest of DATABASE
portion and it worked!
If you are using Windows 7, you might run into problems if your MySQL is configured to use named pipes. Set your MySQL config to use TCP instead.
 Once your reconfigured MySQL allows local network connections, your MySQLdb should work over TCP.  
It doesn't seem to be able to use
Windows 7 named pipes, although the "mysql" command line client can.
There may be a bug.  This wouldn't be noticed unless MySQL
was configured without network connections, which is rare.  I set
up MySQL that way on a development machine with a local MySQL instance.
A detailed article here - http://interconnectit.com/764/using-mysql-workbench-with-xampp/ - shows you the screen where you can switch your Connection Method from named pipes (Local Socket/Pipes) to TCP/IP via Xampp.
Alternatively, if using named pipes (windows) or sockets (linux/mac) for your python/django app to connect to your MySQL is important to you and you do not want to change your connection method to TCP/IP, you should try setting the servername to "." in your xampp's my.conf configuration file; instead of "localhost" or "127.0.0.1". Using pipes/sockets bypasses the TCP/IP network protocol, giving slightly better performance.