Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Cannot connect to database on server

New Here ,
Feb 03, 2012 Feb 03, 2012

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.

TOPICS
Server side applications

Views

1.9K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 03, 2012 Feb 03, 2012

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 03, 2012 Feb 03, 2012

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?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 03, 2012 Feb 03, 2012

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!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 03, 2012 Feb 03, 2012

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines