0

We have two servers.

server 1 and server 2

they are running with Directadmin / CentOS6

my plan:

  • server 1 is running php and html, images...etc.
  • server 2 is running mysql and phpmyadmin

They are all set up using directadmin.

mysql on server 2 is listening on port 4415 and I enabled 4415 port in server 1 and server 2 firewall.

Testing :

  1. created a database on server 2 and "Access Hosts" on directadmin
  2. I uploaded a php-file to server 1 to connect mysql(server2).

It was very very slow and I got this error:

Can't connect to MySQL server on '123.123.123.123' (4)

When I connect to mysql(server2) from "mysql workbench" (my pc) it is very fast and works!

how can I do? I've tested all the way.

  • 1
    Just out of curiosity, did you already check mysql server error log? – VaTo May 14 '15 at 19:08
0

Add user in mysql in this way:

user@server1

This is the way MySQL expect to have user records for remove connection. And permit this user to manage database you use in php application.

User is created in MySQL with command:

CREATE USER 'user'@'server1' IDENTIFIED BY 'password';

And you grant privileges to the user with command like this:

GRANT ALL PRIVILEGES ON database.* TO 'user'@'server1';

where 'database' is the name of your database

  • Thanks, but I created a user on server1 same name and password as server 2 account. but still not work – Sky May 14 '15 at 18:35
  • This user (as described above is created in database, not in OS. Check my edited answer for command – Romeo Ninov May 14 '15 at 18:37
  • I got your mean . But still error(4) – Sky May 14 '15 at 18:51
  • Did you set explicitly in your code to connect to this port (4415)? – Romeo Ninov May 14 '15 at 18:52
  • netstat port listen is show 4415. and my php testing code is : mysql_connect("123.123.123.123:4415","user","password","UTF8") or die(mysql_error()); – Sky May 14 '15 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.