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!

3
  • Did you reset you password as instructed there at the bottom? Commented May 22, 2012 at 11:39
  • No, I didn't but why would it connect using MySQL workbench? Commented May 22, 2012 at 11:41
  • Dom, this error could cause even if there's a version incompaitibility b/w your mysql and PHP. Which version(s) you are in? Commented May 22, 2012 at 11:58

3 Answers 3

1

try..

mysql_connect('IP','USER','PASS', false, MYSQL_CLIENT_SSL);
Sign up to request clarification or add additional context in comments.

2 Comments

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
Do you have the php_openssl extension up and running? php.net/manual/en/openssl.installation.php
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

2 Comments

There is nothing in /etc apart from php5/php.ini
@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
0

here you are php manual mysql connect

see client flags

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.