I have a web server that I can manage via cPanel and I'm trying to connect to a MySql database on a dedicated server (running Ubuntu Server) that I manage. I have two tester connections that give the same error code (from web server to dedicated server).
CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'IP_ADDRESS' (110)
Can't connect to MySQL server on 'IP_ADDRESS' (110)
I also tried on my computer to connect to the dedicated server and I can do it. I'm using HeidiSQL as a GUI client to try connecting and I can connect to it with the same credentials.
What I have tried:
(I'm using Webmin to manage my mysql server)
Set user host to Any
Checked my.cnf for a bind address and it is bound to 0.0.0.0(all ips)
Checked host permissions for specific databases and set the database to my test user and Any for hosts
The Iptable should just allow all because after installing Ubuntu Server I have not changed anything.
I have no idea what else to try.
Related
I have a system in JSP and DB PostgreSQL running on a CentOS 7 server however the error happened in a test VM running Lubuntu
I made an API in PHP with Laravel that sends and receives requests from an APP mobile
Until then everything was working correctly, but if I restart this server I lose the connection with the DB, it will return me this error:
SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
If I try to access the DB through pgAdmin, this returns Connecting to database ... Failed.
The VM accesses correctly through the XenCenter console, however the SSH connection that previously connected correctly is presented Network error: Conection refused
It is as if after restarting blocking all the ports, but until the firewall is disabled
[EDIT]
After some tests I discovered that the problem happens only after enabling mod_rewrite
I am trying to connect mysql database using php. But it is running fine on local machine but not when hosted online and error appeared as
mysqli_connect(): (HY000/2002): Connection timed out
<?php
$link = mysqli_connect('sql6.freesqldatabase.com','user_name','password','database_name');
if(mysqli_connect_error())
die("couldn't connect to database");
?>
Your MySQL server is probably not configured to accept requests from the host you're trying to access it from.
Check the configuration for the server.
Since you say the local machine can access it check where you permitted this and do the same for the ip of the online host.
In my case, AWS firewall was blocking my web server.
Adding the web servers IP address to the firewall exceptions fixed
this for me.
There might firewall in the host which is blocking the request to MySQL server. In my case adding the firewall rule helped me out.
Ubuntu
To allow one device to access the MySQL server,
sudo ufw allow from remote_IP_address to any port 3306
To allow any device to connect to MySQL server,
sudo ufw allow 3306
It worked!
If your website and MySQL database are hosted on separate servers, make sure that you've mentioned correct MySQL hostname (resolvable) in connection string.
In case you've specified the correct username, most probably your MySQL server isn't allowing remote MySQL connections from web server where you site resides.
Contact your web hosting provider for the exact MySQL hostname and to allow your web server IP address for remote MySQL connections.
I think you have to white list your hosting server's ip address to your DB server.
So your DB server will accept requests from your hosting server.
Specify the port (3306?) to the connection string as well.
I need to create replication between two different databases one is localhost database as the master and the second one is the remote server database as slave?
I have a codeigniter web application which is installed on both servers now I want to do that if the internet is not connected all application data should be saved in localhost database, when internet is connected all databases should be copied to the remote server database.
Is there any way I can attain this using localhost phpmyadmin or PHP scripts?
LocalHost Master Setting
How Do I Create Remote Server As Slave
Simple way would be to set up mysql replication. You could set up local mysql server as master and remote server as slave, so that all changes would automatically replicate from localhost to remote host. You also must be able to open mysql port on the remote server to listen to your local machine.
Here would be a basic tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
I work on a dictionary PHP project. Project owner has a dedicated server. They control server files via terminal. And they have a big database which include 370,000 words. In my program I want to connect to database. But the problem is that they don't want to upload my PHP project files to their server. Because they fear that the database maybe stolen by others. They say you can access our mysql server via some server info and they have send some information like this:
server ip : xx.xxx.xxx.xx
Port=3307;
UID=xxx;
pwd=xxxx
The thing that I know is if I want to connect a remote mysql server, The server owner must allow my IP address or upload project files to their server.
They say we don't have a ftp interface and can't allow remote IPs. You can successfully connect via mysql connector which written in php.
Is it possible to connect to the server only with this server information if the server owner not allow to my IP address for mysql connection?
No, it's not possible (with MySQL server default configuration) to connect to a remote MySQL server instance if your user id does not have permission to connect from the remote IP to MySQL server.
If you try to connect to local MySQL server these information would suffice but if you try to connect to a remote host with these information you might get an error like this:
"Connect failed: Access denied for user 'root'#'aa.bb.cc.dd' (using
password: YES)"
This indicates that your user id does not have permission to connect to the MySQL instance from this remote IP address.
But again you can try to connect to the remote MySQL server and get a connection back. It all depends on the remote MySQL server configuration.
The above information is enough to connect to MySQL server through php.
But if the server owner, has disallowed your IP for MySQL port, then you will not be able to connect.
But maybe that isn't the case, the IP disallowing can be application specific.
eg. they can disallow outside IPs to access there FTP and SSH but their MySQL port can be open for outside IP addresses hence can be accessed by you.
I am developing locally and connecting to a remote mysql server. I had been using IIS on my local machine (WinXP) but am now using Apache instead. Most of my PHP site is working correctly after the move to Apache.
But - when mysqli tries to connect to the remote db I get:
(HY000/2003): Can't connect to MySQL server on '...:**' (10060)
I know that the server is accepting connections from my IP because I am able to connect to the same server from my local machine using MySQL Workbench.
I also know that the db connection details I'm using with mysqli are correct because I was using the same details when running on IIS without problem, the only change that happened is that I moved from IIS to Apache.
This problem still exists when my local firewall is disabled.
I have very little experience with Apache, is there perhaps a config setting I've missed that prevents me from connecting out to a remote db, or something that is mangling/hiding reporting of my correct IP?
Thanks for any help, I'm clutching at straws here...
Error 10060 happens when the remote MySQL server does not respond.
It could be that connections to port 3306 on the remote machine are being blocked. It could be that the system hosting PHP/Apache has a software firewall that is blocking the outgoing connection, or that PHP/Apache is not permitted to open network connections by that firewall.