0
votes

I have a database setup non remote server.

What im trying to do is establish the connection using PHP.

All the settings on the server are OK as I tested it using MySQL workbench using following details: Hostname : xxx.xx.xx.xxx Port - blank so as defalut this is :3306

In advanced tab in workbench "Use SSL if available" is selected. Connection test is successful.

Although when Im trying to connect using simple mysq_connect('IP','user','pass') im getting the following errors: line 2 : $c = mysql_connect('IP','USER','PASS');

Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:553) in C:\wamp\www\sql\index.php on line

Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected >in C:\wamp\www\sql\index.php on line 2

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in C:\wamp\www\sql\index.php on line 2

Its been days now when Im trying to establish this connection. Please help!

3
Did you reset you password as instructed there at the bottom?Brian Adkins
No, I didn't but why would it connect using MySQL workbench?Dom
Dom, this error could cause even if there's a version incompaitibility b/w your mysql and PHP. Which version(s) you are in?Rahul

3 Answers

1
votes

try..

mysql_connect('IP','USER','PASS', false, MYSQL_CLIENT_SSL);
0
votes

Quick guide:

  1. Open the server's my.cnf (usually in /etc)
  2. Comment out the old-passwords = 1
  3. Restart MySQL
  4. Run mysql_fix_privilege_tables if necessary
  5. Connect using the mysqlclient utility as root
  6. use mysql
  7. update user set password=password('new password') where user='the user'

Then try again

0
votes

here you are php manual mysql connect

see client flags