I have been trying to share a MySQL database across our internal network but I am having no luck getting it to work. I am using MAMP. I have edited the my.cnf template and commented out the bind-address line so it looks like this: #bind-address = 127.0.0.1
The IP of the machine that is hosting the MySQL database is 192.168.0.152. When I put this IP in when making a MySQL connection via PHP I get the following error:
Can't connect to MySQL server on '192.168.0.152' (61)
Obviously I am missing a step somewhere. What else am I need to do?
Related
I have been helping troubleshoot a process on an old UBUNTU 16 server. We cannot migrate a site to a new server until we understand how it works as we need to recreate and troubleshoot.
Basically its a python3 script that connects to a MYSQL database and reads some data, and updates data under a certain condition. It is basically linked to ZOHO hence the need for this programming language.
The error has been diagonsed as a mysql connection error. Error 111 connection refused. The database is localhost
I have 100% verified the access for the username, password and database visibiity and that port 3306 is open. I can login using a MYSQL command on the CLU and show the database and its tables.
The connector is 100% pulling in the correct variables from the config.py as I have added a print(HOST, DBASE, USER, PASSWORD) just before the connector and verified they are correct.
I have also tried 127.0.0.1 instead of localhost. I have also (dont shoot me) put in the root username and password to remove any permissions issues
I am wondering if its possible to expand on the mysql error in python so I can get a very clear message as to WHAT part is causing an issue. Is there any command in MYSQL that could have been issued to specifically block python.
I have disabled UFW just in case, made no difference, and the general logs for MYSQL dont appear to contain anything useful
Exact error:
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (111 Connection refused)
Note: The server is Ubuntu 16, running MYSQL 5.7.26-0ubuntu0.16.04.1 with localhost access only. Python is 2.7.12
As noted this is an old server, that I want to scrap ASAP but until I can prove that the zoho connector is fixable, we cant proceed as its a blocker.
As you can see in theexample below.
the port is separate from the host
import mysql.connector
cnx = mysql.connector.connect(
host='localhost',
database='import_test',
user='testuser',
password='password***',
port=3306
)
Turns out to be the most basic of all issues. On the old server we cloned from, everyting was open, zero lockdown including MYSQL listening to the world. On the new server, mysql had skip-networking was enabled.
Whereas the web instances were happily connecting directly to the socket, mysql was not activly listening on port 3306. I had changed my.cnf to enable networking but a different issue was stopping those changes taking place.
Once I had mysql working on port 3306 and I could see it listening, python now connected ok so some of the answers were correct. MYSQL was 'not working;' in a global sense.. HOWEVER this is a step backwards in terms of security. I did not want MYSQL open to the world
So I modified the code to use the unix socket of /var/run/mysqld/mysqld.sock, renenabled skip-networking and voila.. all is now fine with python, port 3306 is shutdown again and I have my first trial by fire of python complete
My config file defines DATABASE as local host, USER and PASSWORD but now has SOCKET as /var/run/mysqld/mysqld.sock and my code is
import mysql.connector
from models import ExportRecord
from config import HOST, USER, PASSWORD, DATABASE, SOCKET
def connect():
return mysql.connector.connect(host=HOST, user=USER, passwd=PASSWORD, database=DATABASE, unix_socket=SOCKET)
I'm currently trying to run an application on a server but my customer is very 'picky' about their data and wish to store the database on their own internal office server. I've installed MySQL and can get the application to run locally but for a few specific reasons the application needs to run else where.
I basically can't get access to MySQL from a different location. I think my main stumbling block is port forwarding to the correct location. MySQL is installed on a mac mini with local IP address 192.168.1.242 and the router/modem is an Apple Time Capsule. I've tried looking at tutorials but they all have options that I don't have access to. I've attached a screenshot of the options I have access to and the settings I've tried so far.
Other information possibly needed is:
I need to connect from PHP
I've set a user up within MySQL with a wildcard (%)
I'm testing it using the following: command on my local machine in CMD: mysql -u username -h remote_ip_address -p
I get the following error: ERROR 2003 (HY000): Can't connect to MySQL server on 'REMOTE_IP_ADDRESS' (10061)
Firewall is turned off completely on the Mac Mini
There is nothing in the my.cnf file
OS is Sierra
That's all I can think of at the moment but any advice would be greatly appreciated and any more information required can be provided.
PS. evidently I'm not very good with MAC machines/networks
For anyone that reads this I had a very specific issue. I installed MySQL using homebrew. Homebrew binds MySQL to 127.0.0.1 therefore will only allow connections to MySQL from the same machine no matter what you try to do. To fix it I've had to edit /usr/local/Cellar/mysql//homebrew.mxcl.mysql.plist and replace --bind-address=127.0.0.1 with bind-address=*.
MySQL has an internal firewall of users/IPs. Even if you can connect locally, you might not have permission remotely:
Try this as root user on the MySQL server (locally first!)
GRANT ALL ON <db>.* TO '<user>'#'<remoteIP>' IDENTIFIED BY '<password>';
Where
<db> is the name of the DB
<user> is name under which you connect
<remoteIP> is your external office IP FROM which you are trying to connect
<password> should be self-explanatory!
This will explain the options better
It is impossible to connect to mysql that I setup with phpmyadmin on a debian 8 VPS. I have been searching for hours, I have even followed this guide http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html but nothing, it seems imposible to get to connect to it, I even have created a phpmyadmin profile that is not on localhost and on %...
Thanks a lot for helping...
111 means connection refused, so make sure your mysql config is correct, and check your firewall.
Mysql config details (from Can't connect to MySQL server error 111):
If you have lines like this :
skip-networking
bind-address = 127.0.0.1
In your my.cnf configuration file, you should comment them (add a # at the beginning of the lines), and restart MySQL.
That's the first thing to try. Then try turning off any firewall and connecting again. That will tell you whether there's a firewall problem.
I'm having a trouble accessing the database in my godaddy account. I already created a database in phpmyadmin and a user in mysql database
I need to access the database in my godaddy account using my localhost.
But when i run my code, i'm getting a host xxxx is not allowed to connect to this mysql server
below is what i used in config
Public consqlonline As String = "server=Website_ipAddress;user=uname;password=pass;database=syncing;Connect Timeout=2000"
you need to give a privilege to connect the specific database that the application need to connect, via PHPmyadmin >> choose database >> use privileges tab.
by the way i had this problem also and my server was running on Linux, by default the configuration of the server permit connection only from localhost, so to fix that ive edited /etc/mysql/ my.cnf file: changed the bind-address from 127.0.0.1 to 0.0.0.0 (if the version is kind of old you have to comment the "skip-networking" command
I am adding the facebook authentication to my django application using the link http://goo.gl/hQ5nx5. I am using Wampserver for Mysql. There's a direction in the above link at step-4 to add an entry in the C:/Windows/System32/drivers/etc/hosts file that maps 127.0.0.1 to something like test1.com. But after this when I run my server through cmd, it gives the error: Can't connect to mysql server on 'localhost' (10061).
Kindly suggest me the solution to this problem. Thanks.
Is your settings.py pointing at localhost? You could adjust it
to point to test1.com, but that's likely to then cause issues when
you change back, so a better answer is:
/etc/hosts supports multiple hostnames for an ip address. You probably want a line like
127.0.0.1 localhost test1.com