[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

php help with mysql_connect

Posted on 2010-03-23
13
Medium Priority
?
504 Views
Last Modified: 2013-12-13
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

0
Comment
Question by:jimbona27
13 Comments
 
LVL 13

Expert Comment

by:Gregory_V
ID: 28354869
Create a new user ID and password for the database and retry.
0
 

Author Comment

by:jimbona27
ID: 28355730
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
 

Author Comment

by:jimbona27
ID: 28356412
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 

Author Comment

by:jimbona27
ID: 28357005
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
 
LVL 13

Expert Comment

by:Gregory_V
ID: 28359534
Hmm, DBForge will have a security manager that will give you user names and access rights for each database.

0
 

Author Comment

by:jimbona27
ID: 28361278
its empty...?
0
 

Author Comment

by:jimbona27
ID: 28361358
any ideas?
gtrab.GIF
0
 
LVL 13

Assisted Solution

by:Gregory_V
Gregory_V earned 200 total points
ID: 28362477
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
 

Author Comment

by:jimbona27
ID: 28431548
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
 

Author Comment

by:jimbona27
ID: 28432299
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
 
LVL 17

Expert Comment

by:Shinesh Premrajan
ID: 28541160
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
 
LVL 1

Accepted Solution

by:
Aulto earned 1000 total points
ID: 28915351
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
 
LVL 2

Expert Comment

by:Mehul_Panchal
ID: 29782173
i think you r using old version

Thanks
Mehul Panchal
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question