user2307598
user2307598

Reputation: 33

Cannot establish remote mysql connection

I recently moved a few websites of mine from one hosting to another, but I decided to keep databases on the old hosting.

I did all the steps:

  1. whitelisted new server's IP
  2. changed all dbcon config ''localhost'' to old server IP
  3. even changed outdated ''mysql_connect'' with mysqli Still I cannot establish db connection at all! How do I troubleshoot this? I have bno idea where else to look!

There might be some issues with PHP in the new hosting!

In PHP settings, the dropdown menu of ''Select PHP version" has only WARNING:Alternatives and ERROR:User options. Shouldn't there be PHP versions???

Upvotes: 1

Views: 118

Answers (1)

RolandoMySQLDBA
RolandoMySQLDBA

Reputation: 44373

You may have to look at the MySQL user connections from within MySQL.

Here is what you do:

SELECT user,host FROM mysql.user;

This will reveal where each MySQL user can connection from.

If a user has host='%', then that user can connect from anywhere.

If a user has host='10.20.30.%', then that user can connect from '10.20.30.%' netblock only.

Let's take the latter case: a specific netblock.

Suppose your new servers are on netblock 20.30.40.%. You may have to go to each user and change the netblock in mysql.user.

EXAMPLE: For the user myuser.'10.20.30.%', and you want to change myuser to access MySQL from netblock 20.30.40.%, you would login to the DB server, connect to mysql as root@localhost, and execute this:

UPDATE mysql.user SET host='20.30.40.%' WHERE host='10.20.30.%';
FLUSH PRIVILEGES;

This will update every user's host column with the new netblock.

You could always use the GRANT command instead of hacking it like I just suggested.

If you cannot change mysql.user in either way, you may have to ask the DB Host provider to do that for you.

Give it a Try !!!

Upvotes: 2

Related Questions