0

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!

Community
  • 1
  • 1
Dom
  • 3,126
  • 14
  • 46
  • 68

3 Answers3

1

try..

mysql_connect('IP','USER','PASS', false, MYSQL_CLIENT_SSL);
Lee Davis
  • 4,685
  • 3
  • 28
  • 39
  • I tried that. Now I have the following error Warning: mysql_connect() [streams.crypto]: this stream does not support SSL/crypto in C:\wamp\www\sql\index.php on line 2 – Dom May 22 '12 at 11:47
  • Do you have the php_openssl extension up and running? http://php.net/manual/en/openssl.installation.php – Lee Davis May 22 '12 at 11:56
0

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

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
  • There is nothing in /etc apart from php5/php.ini – Dom May 22 '12 at 11:51
  • @Dom well, check the output of `SELECT PASSWORD('test');` and make sure it's ehh ... long :) if not, you will have to look for the `my.cnf` – Ja͢ck May 22 '12 at 11:55
0

here you are php manual mysql connect

see client flags

anjalis
  • 397
  • 2
  • 19