Reputation: 4003
So I'm trying develop on my local machine, while using one database on my remote server.
To do this I've tried changing the myql_connect line.
from
$con = mysql_connect("localhost", "username", "pw");
to
$con = mysql_connect("mydomain.com:2082", "username", "pw");
and now I'm getting the following errors
Warning: mysql_connect() [function.mysql-connect]: MySQL server has
gone away in C:\xampp\htdocs\posts\index.php on line 27 Warning:
mysql_connect() [function.mysql-connect]: Error while reading greeting
packet. PID=5092 in C:\xampp\htdocs\posts\index.php on line 27
Warning: mysql_connect() [function.mysql-connect]: MySQL server has
gone away in C:\xampp\htdocs\posts\index.php on line 27 Fatal error:
Maximum execution time of 30 seconds exceeded in
C:\xampp\htdocs\posts\index.php on line 27
I don't really understand what the :2082 is or what it does. In the examples on the php page it uses :3307, but when I log into cpanel on my remote server it always has :2082 after my domain name. In any case 3307 doesn't work either.
Can anyone help me figure out what I'm doing wrong? (or should I be doing something different -- like changing the mysql default host somewhere in the php.ini[??] and then continue to use local
host in the mysql_connect
?
Thanks for your help.
Upvotes: 0
Views: 4871
Reputation: 11
Please contact to remote server administration and ask to give permission to your server IP address for access their database from your server/website.
Upvotes: 0
Reputation: 3986
That :2082
is the port which mySQL is trying to connect to. It however, will not be the same port as your cPanel. :3307
is the port mySQL traditionally listens on.
I don't use cPanel much, but I believe it tends to set up a subdomain mysql.yourdomain.com
that you can connect to.
Past that, make sure that you setup the mySQL user to be able to connect from your local machine.
Upvotes: 1