php help with mysql_connect

Hi ee,
I have this line of code to connect to a remote database but I get the following error:


Warning: mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter than expected in C:\wamp\www\conn.php on line 15

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using old authentication in C:\wamp\www\conn.php on line 15
Could not connect: mysqlnd cannot connect to MySQL 4.1+ using old authentication


can someone please advise how I can resolve this issue?
Thanks,
$con = mysql_connect('x.x.x.x', $strDatabaseUser, $strDatabasePassword);

Open in new window

jimbona27Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gregory_VCommented:
Create a new user ID and password for the database and retry.
0
jimbona27Author Commented:
can you show me how to do that as I only have dbforge to manipulate the database.  im used to phpmyadmin and ms sql studio..???

thanks,
0
jimbona27Author Commented:
i've tried this:

grant usage on database_name.* to user_name@localhost IDENTIFIED BY ’somepassword’ WITH GRANT OPTION;

and not I get
Access denied for user 'name@x.x.x.x' (using password: YES) 

Open in new window

0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

jimbona27Author Commented:
i've noticed the IP address stated in the error is different to the IP I set within the mysql_connect command.

please note: I am behind a VPN client although this is running and DBForge can connect to the IP address im using in the connect command..
0
Gregory_VCommented:
Hmm, DBForge will have a security manager that will give you user names and access rights for each database.

0
jimbona27Author Commented:
its empty...?
0
jimbona27Author Commented:
any ideas?
gtrab.GIF
0
Gregory_VCommented:
Wondering how much access you have here.  You can't create users, you have access denied and you don't see any users.

Perhaps time to reach someone who has more privileges to the server.
0
jimbona27Author Commented:
i've spoken to the people that host the database and they are using PHP 5.1 whereas we are using 5.3

any suggestions?  can I use a different method to connect or something?
Thanks,

this is the error:


Warning: mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter than expected in C:\wamp\www\try.php on line 10

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using old authentication in C:\wamp\www\try.php on line 10
Unable to select database
<?php

class DB {	
	var $conn;

	function __construct() {
		$user = "xxx";
		$password = "xxx";
		$db = "xxx";
		$this->conn = mysql_connect('xxx', $user, $password);
		@mysql_select_db($db) or die("Unable to select database");
	}		
	
	function getConn() {
		return $this->conn;
	}
}

$db = new DB();
;?>

Open in new window

0
jimbona27Author Commented:
i've tested the code on the actual server and it works but for me using WAMP (which is PHP 5.3) it fails..

0
Shinesh PremrajanEngineering ManagerCommented:
This is generally a fairly simple problem, the password in the database is using the older short hash method instead of the newer method.

To fix these reset the password
SET PASSWORD FOR 'user'@'localhost' = PASSWORD(newpassword');

This is what actually causing you this problem:
http://www.bitshop.com/Blogs/tabid/95/EntryId/67/PHP-mysqlnd-cannot-connect-to-MySQL-4-1-using-old-authentication.aspx
0
AultoCommented:
you are trying to connect to a remote mysql db, huh?
if so, you should set what's the port of the connection:
mysql_connect('127.0.0.1:3606', 'root', '123');
assure this port is not protected or something.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mehul_PanchalCommented:
i think you r using old version

Thanks
Mehul Panchal
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.