Copy link to clipboard
Copied
I am having problems connecting to a MySQL database on the remote server using Dreamweaver CS5. I can connect locally to a copy of the database on my local machine and all work OK, I can see the tables etc. However, I have set up a connection to a copy of the same database on my remote server, and when I try to access the database, or try the test button I get error #1045 - Access denied for user 'mike'@'localhost' (using password YES). I am connecting via WampServer 2. Any help resolving this would be much appreciated.
Copy link to clipboard
Copied
I'm not real good at this but encountered a very similar problem a while back. After several tries, reviews and changes, I learned that I needed to add my login-ID for my web site host ahead of my $database_... and $username_.... This was a requirement of my site host. The following is the connection file contents (for the sample in the tutorial by Mr Powers).
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_check_mag = "localhost";
$database_check_mag = "xxxxx_phptest"; (the 'xxxx' is my login ID for my live site host, the 'phptest' is the name of the site )
$username_check_mag = "xxxxx_tester"; (the 'xxxx' is the login ID for my live site host, the 'tester' is the login name for the database)
$password_check_mag = "yyyyyyyy"; (the 'yyyyy' is the password for the database)
$check_mag = mysql_pconnect($hostname_check_mag, $username_check_mag, $password_check_mag) or trigger_error(mysql_error(),E_USER_ERROR);
?>
My host uses 'cPanel' for its front end service.
Tom
Copy link to clipboard
Copied
Not sure what you mean by login ID for live site host - do you mean the username for logging in to C Panel?
Copy link to clipboard
Copied
Exactly. It was never explained to me why but as soon as I added the login ID in front of the two names ($database... and $user...) it worked perfectly. Of course, I did have to go back to my local testing server and also change the names there too!
Copy link to clipboard
Copied
1) Do you have same database created in cPanel? If not, first create it.
2) Create a user for that database. cPanel will put root username and underscore as prefix.
Example: your username for cPanel "mike", and you created a database user named "dbadmin".
The user for the database will be: mike_dbadmin
3) Add user to the database. Please read "Define a User's Privileges" section: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/MySQLDatabases
4) Create all the tables. Easiest way to do it is, first export your whole local database with phpMyAdmin and then import it to your live server with phpMyAdmin.
If you still can't connect, try to add your IP to remote access host: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/RemoteMySQL
If still out of luck, then probably firewall in the server is blocking inbound connections to MySQL port (normally 3306). Talk to your host and ask them if they can come with a solution.