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 this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

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
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
8,310 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
n/a Points
2014-05-09 5:52 am

how i run php  program in server 

Staff
17,014 Points
2014-05-09 10:55 am
Hello Shiv Krishna,

Files that are written in php and end with the extention .php are interpreted by the php engine on the web server when they are called. You do not have to do anything special to make them run.

Kindest Regards,
Scott M
n/a Points
2014-05-30 7:28 pm

I have this error but in my "local host" installed in my computer by xamp. I can´t access to  my sites and I don´t access to priviliges eigther.

 

 

Staff
16,176 Points
2014-05-30 8:09 pm
Hello Sara,

I'm sorry to hear that you're having problems with your "localhost" computer. Since this issue is not on our servers, I cannot look at it directly. You will need to determine the proper user access credentials for the user that is accessing the database. That is the core of the problem. If you have no privileges to access the database or change the permissions, then you will not be able to correct the issue. Unfortunately, since the server is not something we can control, then we cannot take action to fix the problem.

I hope this helps to lead you to the solution. Please let us know if you have any further questions or comments.

Regards,
Arnel C.
n/a Points
2014-06-03 6:35 am

Hello everyone,

I installed xampp created .php extension files and added database through mysql.

My whole code is running nicely on my laptop,but when I uploaded my files in a free hosting account. error "Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) in /home/u153721562/public_html/SF/connect.inc.php on line 7 Access denied for user 'root'@'localhost' (using password: NO)" came and my files are not running.

Please suggest some measures to sort it out.

Staff
8,065 Points
2014-06-03 8:04 am
This is due to a password not being defined and your MySQL server requiring one. You will need to define the correct user and password within your code to appropriately connect to your MySQL server.
n/a Points
2014-06-03 8:31 am

Could you give me the appropriate code for changing the password of root user.

and how to then connect to database/localhost

Staff
8,065 Points
2014-06-03 8:35 am
We are not very familiar with XAMPP, but I was able to find an article on changing your MySQL root password in XAMPP.

Once done, you will need to adjust any code that you have written to connect to the database. This step can greatly vary and if you are unsure of how to do so, I recommend contacting your developer.
n/a Points
2014-07-21 11:41 am

Hey mate, May be its kind of late now but in case you are still stuck with the same issue, you need to edit your connection.php file or whatever file you use to connect to database. change the username and the password to the ones you use to log in to the cpanel. That will solve the problem

n/a Points
2014-06-07 2:13 pm

I have followed all of the steps of the article. I have created a database equivalent to the "training_employee" example, but this is where it goes haywire. Do I copy and paste the "employee" databse equivalent and paste it into the SQL of my "training_employee" database or do I edit the "employee" database and import it into the "training_employee" database? Sorry if this was confusing!

Staff
17,014 Points
2014-06-09 12:08 pm
Hello Mora,

If you are moving data from one database to another, you can simply export the data from the source database and then import it into the target database. This is provided both have been created in the cPanel.

If that does not answer your question, please reply so that I may continue to assist.

Kindest Regards,
Scott M
n/a Points
2014-07-05 11:20 am

When I Import my database into phpmyadmin it have some problem that mean error SQL query: Dumping data for table 'cds' it how can I fix it this kinds of problem please! Please suggest me.

Staff
9,962 Points
2014-07-06 3:06 am
Hello Girmaye,

Usually when that happens it means the database you're trying to import the backup into already has a cds table.

You might want to check before running your import, and drop all of the tables from the current database.

To drop all tables in phpMyAdmin you would simply click on the database name on the left, and then click on the Check All checkbox. Next from the With Selected: drop-down, choose Drop.

Hopefully that helps, if not please let us know if the SQL error mentions anything else that might be of help to us troubleshooting it.

- Jacob
n/a Points
2014-08-25 5:07 pm

I did exactly as you say in the tuto but it gave me this message:

Import has been successfully finished, 0 queries executed. (c374739_dictionnaire25_08_14.sql.zip)

==================================

or before your tuto the error message was:

Error

SQL query:

---- Database: `c374739_dictionnaire`--CREATE DATABASE IF NOT EXISTS `c374739_dictionnaire` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

MySQL said: Documentation#1044 - Access denied for user 'C374739_kalle'@'%' to database 'c374739_dictionnaire'

===============================================

 

-- phpMyAdmin SQL Dump-- version 4.0.4-- http://www.phpmyadmin.net---- Host: localhost-- Generation Time: Aug 25, 2014 at 08:19 PM-- Server version: 5.6.12-log-- PHP Version: 5.4.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8 */;

---- Database: `c374739_dictionnaire`--CREATE DATABASE IF NOT EXISTS `c374739_dictionnaire` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;USE `c374739_dictionnaire`;

-- --------------------------------------------------------

---- Table structure for table `mots`--

DROP TABLE IF EXISTS `mots`;CREATE TABLE IF NOT EXISTS `mots` (  `ID` smallint(6) NOT NULL AUTO_INCREMENT,  `mot` varchar(250) NOT NULL,  `audio` varchar(500) NOT NULL DEFAULT 'defaultDefault.WAV',  `definition` varchar(10000) NOT NULL,  `son` varchar(500) NOT NULL DEFAULT 'defaultDefault.WAV',  PRIMARY KEY (`ID`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2018 ;

Staff
16,176 Points
2014-08-25 5:55 pm
Hello Kayen,

Sorry to hear that you're having problems with a database import. The article written above was done with understanding that you're using cPanel and a system similar to our own hosting setup here. By default, databases are named in a specific convention per the user name on your account. Your error messages indicate you're not using our conventions, so the error message is probably different in your case. It may have to do with your level access to the database. The instructions above are bypassing the creation of the table section and you're doing it with PHPMYADMIN. Then you should be running an import with an SQL file, not a ZIP file. The message that you've given to us indicates you're trying to run the ZIP file for the import. Please review your import process. Again, we generally try to provide advice on all types of issues - but our main focus is providing support for InMotion's hosting service and our system. In the event that we may not be able to provide the information you require, then you may need to seek the advice of a programmer. They would be required to to perform the necessary changes for your code to work.


Kindest regards,
Arnel C.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

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

21 Questions & Comments

Post a comment

Back to first comment | top

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!