Mysql connection error


When I try to connect to my database from a PHP script I get the followng error;

Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘user’@‘’ (using password: YES) in /home/.nocturne/user/ on line 10

On line 10, I’ve written mysql_connect(“”, “user”, “password”) or die(“error”);

I can connect locally machine using EMS SQL Manager, because I entered my local ip address in “From what hosts (computers) may myuser connect to these databases”, but my script cannot connect to mysql. “” also exists in “From what hosts (computers) may parskunt connect to these databases” section.

I dont know what to do. Any help will be appriciated.

Are you sure you are using the correct host name for your database, and not the database name?

For instance, if I have a database named “db”, I cannot connect to it via the code you posted by using “”; I have to connect to using “”. You can view the hostname a database is assigned to in the Control Panel–>goodies–Manage MySQL. By default, Dreamhost usually assigns “” as a host unless you name it differently or create an additional host (alias).

I suggest you double check for the correct hostname usage, as I suspect that is where your problem lies (given, of course, that your user/pass is correct :wink: ). Good luck, and let us know if that was, in fact the problem, ok?


Thanks for your reply,

I’ve setup wordpress from “one-click installs” section and it works fine. My db server name is “” and I can connect it with phpmyadmin.

Wordpress config is;

define(‘DB_NAME’, ‘parsblog’);
define(‘DB_USER’, ‘parskunt’);
define(‘DB_HOST’, ‘’);

I use the same host, user, and password from Wordpress config file, I only change the database name, but I cannot connect to my db.

Wordpress mysql connection is
define(‘DB_NAME’, ‘parsblog’);
define(‘DB_USER’, ‘parskunt’);
define(‘DB_HOST’, ‘’);
@mysql_connect($dbhost, $dbuser, $dbpassword);

while mine is
$hostname = “”;
$username = “parskunt”;
$password = “XXXXXXXXXX”;
$database = “parskunt”;
mysql_connect($hostname, $dusername, $password);


EDIT: I’ve solved the problem. I’ve “defined” all 4 variables then the problem is gone;

define(‘DB_HOSTNAME’, ‘’);
define(‘DB_USERNAME’, ‘parskunt’);
define(‘DB_DATABASE’, ‘parskunt’);

I dont know why this is the way it works but that solved my problem.

Looks like your problem had to do with using double quotes on the hostname. The host name had periods in it, so it should have used single quotes.

My website