MySQL Forums
Forum List  »  PHP

Re: MySQL connection error
Posted by: Jonathan Stephens
Date: June 21, 2005 08:22AM

> $host = "localhost:3036";

The default port for MySQL 3306, not 3036. But normally there's no reason even to specify the port.

One thing that will help you figure out why your connection failed is to use the mysql_error() function:

$link = mysql_connect($host, $user, $password)
or die("DB connection failed because: " . mysql_error());

This will output an error message in the event of failure.

> Peraps your server encrypted the password. and client program sends the password without
> encryption. New MySql Servers with old client gives this problem.

Not quite. The pre-4.1 client library uses a *different* encryption algorithm. But please don't say that it uses no encryption at all, because this isn't the case.

> A password is something like a token to validate the right user who has rights to use all the
> tables in a Database.

It's more correct to say that a password validates a user, and that this user can have any combination of rights on tables and table columns in one or more databases.

> Your have to use ur root user account to log in; not ur database name or the user you
> created the 'admin' password for.

This is not true, and it's actually a *very* bad idea to use the root account/password for an application. Best practise is to create a user for each application with only the privileges necessary for that application.

BTW, it's best not to use mysql_pconnect(). Persistent connections tend not to be very efficient, and for this reason they're not supported in PHP 5's new mysqli extension.

Jon Stephens
MySQL Documentation Team @ Oracle

MySQL Dev Zone
MySQL Server Documentation
Oracle



Edited 1 time(s). Last edit at 06/21/2005 08:33AM by Jon Stephens.

Options: ReplyQuote


Subject
Written By
Posted
June 16, 2005 03:05PM
Re: MySQL connection error
June 21, 2005 08:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.