This page will assist you with troubleshooting a MySQL - 1044 "Access Denied" Error Message.
When you import a database using phpMyAdmin, generally you are importing a text file with a .sql extension.
Here is a section of code that may be in a .sql database backup. In this example, the database we are trying to import is named employees.

-- phpMyAdmin SQL Dump
-- version 2.11.9.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 02, 2010 at 08:01 AM
-- Server version: 5.0.81
-- PHP Version: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE DATABASE employees;
-- --------------------------------------------------------
--
-- Table structure for table `employee_list`
--
CREATE TABLE IF NOT EXISTS `employee_list` (
`first_name` text NOT NULL,
`last_name` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

When using phpMyAdmin to attempt to import such a file, you will receive an error message similar to:
Error
SQL query:
CREATE DATABASE employees;
MySQL said: Documentation
#1044 - Access denied for user 'training'@'localhost' to database 'employees'

In this scenario, my cPanel username is training. Because of cPanel's database naming conventions, all database names must begin with the cPanel username followed by an _. I cannot create a database named employees, however I can create a database named training_employees.
The reason this import failed is because of the following line in the .sql file (shown above)

CREATE DATABASE employees

Again, I cannot create a database named employees, however I can create a database named training_employees.

If I change the line that says:
CREATE DATABASE
so that it creates:
training_employees
instead of employees
it will again fail with the following message:
Error
SQL query:
CREATE DATABASE training_employees;
MySQL said: Documentation
#1044 - Access denied for user 'training'@'localhost' to database 'training_employees'

When using cPanel, databases must be created within the cPanel itself.
To fix the issue, you will need to:
  1. Create the: training_employees database within cPanel
  2. Comment out the: CREATE DATABASE command in my .sql file. To do this, simply change: CREATE DATABASE employees; to -- CREATE DATABASE employees; You are simply adding dash dash space to the front of the line to comment it out so that it will not be executed.
  3. Log into phpMyAdmin, access the training_employees database, and then import as normal
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve our Support Center:
Email Address
Optional, but our team may contact you for more information.
Like this Article?

Comments

Post a comment
n/a Points
2014-04-04 8:30 pm

Thank you. Really struggled as a newbie to SQL and found your article which sorted everything out....thanks so much!!!

n/a Points
2014-04-16 4:20 am

How do you comment out the statement in the .sql file? is there an editor for it?

Staff
5,472 Points
2014-04-16 9:33 am
Hello Beep,

Thank you for your question. You can edit the .sql file with a text editor, such as notepad in Windows:

  1. Right click the .sql file.

  2. Click Open with

  3. Click notepad

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul

Post a Comment

Name:
Email Address:
Comment:
Are you a bot?
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!