MySQL Connection Issues(PHP)


#1

I have the following script: the username, domain, password, and database are all correct. Still, for whatever reason, I can’t connect. I also have my IP listed so I can connect remotely.

Is there anything specific I’m doing wrong?


#2

Can you connect from the command line? (i.e)

[waratahs:/home/coolgeek]$ mysql -u user -p -h mysql.xxxxx.com dbname

I include a version of this script in all of my php scripts

<?php # mysql_connect.php

// Set the database access information as constants.
DEFINE ('DB_USER', 'xxxxx');
DEFINE ('DB_PASSWORD', 'xxxxx');
DEFINE ('DB_HOST', 'mysql.xxxxx.com');
DEFINE ('DB_NAME', 'xxxxx');

// Make the connnection and then select the database.
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)
    or die (mysql_error());
mysql_select_db (DB_NAME);
?>

#3

Here is my output when I try to do that…

[code]Variables (–variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)


auto-rehash TRUE
character-sets-dir (No default value)
column-type-info FALSE
comments FALSE
compress FALSE
debug-check FALSE
debug-info FALSE
database (No default value)
default-character-set latin1
delimiter ;
vertical FALSE
force FALSE
named-commands FALSE
ignore-spaces FALSE
local-infile FALSE
no-beep FALSE
host (No default value)
html FALSE
xml FALSE
line-numbers TRUE
unbuffered FALSE
column-names TRUE
sigint-ignore FALSE
port 3306
prompt mysql>
quick FALSE
raw FALSE
reconnect TRUE
socket /var/run/mysqld/mysqld.sock
ssl FALSE
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cert (No default value)
ssl-cipher (No default value)
ssl-key (No default value)
ssl-verify-server-cert FALSE
table FALSE
user holsch4
safe-updates FALSE
i-am-a-dummy FALSE
connect_timeout 0
max_allowed_packet 16777216
net_buffer_length 16384
select_limit 1000
max_join_size 1000000
secure-auth FALSE
show-warnings FALSE[/code]

And my error when using constants:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'hamal.dreamhost.com' (using password: YES) in /home/user/mydomain.com/sql.php on line 7 error


#4

One of the values specified in your connection string/parameters is incorrect.

Check the cpanel https://panel.dreamhost.com/index.cgi?tree=goodies.mysql& to confirm the database name, hostname and user name. If you are correctly specitying all of these in your connection string/parameters, click on the user name and change its password