Question : Mysql Script Wont Connect to Remote Server

My coder recently parted ways, and I recently moved to a new mysql server, this is causing a script he made to break. Unfortunately I have no familiarity with php and only slight familiarity with mysql, so I'm looking to the experts for some help.

I seem to be getting quite a few mysql errors, I have already changed the script to reflect the new server.

Here is the part in the script that has connection info, it all seems to be right:

function tc_mq($query) {
      $host = 'panel.*******.com';
      $username = 'dbname';
      $password = '*****';
      $db = 'dbname';
      mysql_pconnect($host,$username,$password);
      mysql_select_db($db);
      return mysql_query($query);
}


I made sure that info is correct, I also issued the GRANT command on the new mysql server to allow that remote ip to connect, what else could I be doing wrong?

Thanks, Brad
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
Warning: mysql_pconnect() [function.mysql-pconnect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/admin/public_html/testserver/create.server.php on line 294
 
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'admin'@'localhost' (using password: NO) in /home/admin/public_html/testserver/create.server.php on line 295
 
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/admin/public_html/testserver/create.server.php on line 295
 
Warning: mysql_query() [function.mysql-query]: Access denied for user 'admin'@'localhost' (using password: NO) in /home/admin/public_html/testserver/create.server.php on line 296
 
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/admin/public_html/testserver/create.server.php on line 296
 
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/admin/public_html/testserver/create.server.php on line 67
 
Warning: mysql_pconnect() [function.mysql-pconnect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/admin/public_html/testserver/create.server.php on line 294
 
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'admin'@'localhost' (using password: NO) in /home/admin/public_html/testserver/create.server.php on line 295
 
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/admin/public_html/testserver/create.server.php on line 295
 
Warning: mysql_query() [function.mysql-query]: Access denied for user 'admin'@'localhost' (using password: NO) in /home/admin/public_html/testserver/create.server.php on line 296
 
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/admin/public_html/testserver/create.server.php on line 296
 
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/admin/public_html/testserver/create.server.php on line 106
 
Warning: mysql_pconnect() [function.mysql-pconnect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/admin/public_html/testserver/create.server.php on line 294
 
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'admin'@'localhost' (using password: NO) in /home/admin/public_html/testserver/create.server.php on line 295
 
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/admin/public_html/testserver/create.server.php on line 295
 
Warning: mysql_query() [function.mysql-query]: Access denied for user 'admin'@'localhost' (using password: NO) in /home/admin/public_html/testserver/create.server.php on line 296
 
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/admin/public_html/testserver/create.server.php on line 296
 
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/admin/public_html/testserver/create.server.php on line 214
Open in New Window Select All

Answer : Mysql Script Wont Connect to Remote Server

The manual teaches you how to add users and permissions to go with that user;
http://dev.mysql.com/doc/refman/5.0/en/adding-users.html

I suggest reading this page for a full understanding.
1:
2:
3:
4:
5:
6:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';
Open in New Window Select All
Random Solutions  
 
programming4us programming4us