MySQL – 1044 Access Denied Error Message

This page will assist you with troubleshooting a MySQL – 1044 “Access Denied” Error Message.

Troubleshooting the MySQL 1044 “Access Denied” Error

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 -- https://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:

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.

68 thoughts on “MySQL – 1044 Access Denied Error Message

  1. Hello,

    @Tim S… I did have a question but as you can see I have answered it myself after reading your link. My version is the definitive answer. Pls check.

    Regards,

    Aziz

    1. Hello Aziz,

      Thanks for your response and clarification. If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  2. — Server version: 5.6.12-log
    — PHP Version: 5.4.16

    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: `ilan_sitesi`

    /* CREATE DATABASE IF NOT EXISTS `ilan_sitesi` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    USE `ilan_sitesi`;*/;

    The last line has to be commented out. Then the import takes place without any problems.

    Regards,

    Note: Watch out for multiline comment out (single line — doesn’t work although the sql is  single line)

  3. hiii….i am getting an error like this   #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘? ’ at line 1

    while importing a table from my local db to cpanel db.  Can u help me please 

     

     

  4. This is the answer to enswer to error #1044:

    When in cPanel’s phpMyAdmin don’t start importing yet. First find the sql database file you have exported from your local machine’s phpMyAdmin which you might have named mysite.sql and open it with a text editor such as wordpad or notepad and add in front of the name of the database which is just at the begining of the code the domain name prefix which you have been issued by cPanel. yourDomain_mysite

    See My Examples below:

    Before

    CREATE DATABASE IF NOT EXISTS `mysite` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    USE `mysite`;

     

    After

     

    CREATE DATABASE IF NOT EXISTS `mydomain_mysite` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    USE `mydomain_mysite`;

     

    Note: To create a database called mysite in cPanel your domain will always be the prefix.  Create database mysite and you will get yourdomain_mysite

     

    Thank You All

    Cheers

  5. I followed the instructions above by commenting out the create database and still get this:

     

    SQL query:

     


    — Database: `soh`

    — CREATE DATABASE `soh` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
    USE `soh` ;

     

    MySQL said:

    #1044 - Access denied for user 'cpses_yaRwoQA1K7'@'localhost' to database 'soh'

    1. Hello Cheryl,

      Have you added the user cpses_yaRwoQA1K7 to have access to the database soh? If so does the user have create permissions? Permissions are selected when the user is added. Are you sure the password you are using is correct?

      Best Regards,
      TJ Edens

  6. Hey guys… been pulling out my hair with this one. I’m using securedphp for a private portal:

    /****** Database ******/

    $useDatabase = true;                     // Choose between using a database or data as input

     

    /* this data is necessary if a database is used */

    $cfgServerHost = 'sql105.byethost22.com';             // MySQL hostname

    $cfgServerPort = '3306';                      // MySQL port - leave blank for default port

    $cfgServerUser = 'b22_17861366';                  // MySQL user

    $cfgServerPassword = '********';                  // MySQL password

     

    However when I try to log into the page with my credentials I get:

     

    Access denied for user ‘b22_17861366’@’192.168.0.%’ to database ‘b22_17861366_user’

     

    help 🙁

    1. Hello Claire,

      Sorry for the problem. We were thinking several things when we first saw your comment. We normally would need to have more information because we aren’t seeing the actual query. However, we were looking closely at your $cfgServerHost line – it looks like it has a typo in it. Please check that out first – hopefully that’s all there is to your problem.

      If you have any further questions, please let us know.

      Kindest regards,
      Arnel C.

    1. Hello, Stephen, cPanel is a web hosting tool that comes pre-installed with our hosting packages. Likewise, our customers receive a cPanel username they can use to log in.

  7. I have created and used a database, which i used to connect with netbeans ide 8.0.2

    and now, when i use the same database in mysql, it gives the following error

    Error 1044 (42000): Access denied for user ‘ ‘@’localhost’ to database ‘<databasename>’

    I used ‘SHOW DATABASES;’

    it shows 

    DATABASE
    information_schema

    test

     

     

    I am very sure that my Database name i used was right 

    Someone please help me

    And if I use the abovementioned method, will it affect my java program i made from working right?

    please help!

    1. Hello Anurag,

      Have you added the user to the database. Are you able to run “mysql -p -u user database” and log in correctly?

      Best Regards,
      TJ Edens

  8. I followed your suggestions and was able to import a databse without any errors! However, when I go to the “Databases” tab of myphpMyAdmin, it says “No databases”! What should I do/

    1. Hello Pikov,

      If your database imported and you still cannot see it, it may be an ownership/permission issue. You will want to check with our Live Suport team to have them check on that for you.

      Kindest Regards,
      Scott M

  9. I’m having problem with importing database while moving my site to a new host.

    I backed up the old database and when trying to uplad it to the new host via phpMyAdmin  i get this kind of error:

     

    Requête SQL:


    — Base de données: `rhinopl2_wp942`

    CREATE DATABASE IF NOT EXISTS  `rhinopl2_wp942` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    MySQL a répondu: Documentation

    #1044 – Access denied for user ‘rhinopla’@’localhost’ to database ‘rhinopl2_wp942’

    I tried to encode the database and save it with notepad using this UTF8  while saving but still getting the above error

     

    Can you please take time to help me as i’m stucked here

    Thank you

     

     

     

     

     

    1. Claude,

      Thank you for contacting us. Since this is an “Access Denied” error, ensure the user ‘rhinopla’@’localhost’ has access to database ‘rhinopl2_wp942’. Here is a helpful link to our guide on How to create and attach a database user in cPanel.

      You can view your database and user names in cPanel, by clicking the MySQL Databases button in the Databases section.

      Thank you,
      John-Paul

  10. i did this before i even found this site for my error but oddly i get this error

     

    #1044 - Access denied for user 'pevonyco'@'localhost' to database 's2'

     

    ‘s2’ is random and idk wheres its coming from. ideas?

    1. Hello novabomb,

      Check the code you are using to connect to see which variable is entering ‘s2’.

      Kindest Regards,
      Scott M

  11. MySQL – 1044 Access Denied Error Message same issue i am facing but in my case i have multiple db’s, is there any other way to import multiple db’s, the above suggested solution to create db’s, select the db and then import one by one, what if i have 100’s of db’s

    1. Hello Pradeep,

      The number of databases that you can use with MySQL will depend on your account type. If you’re on anything less than a PRO account, then you will have limits on the number of databases that can be imported. You can also upload the database files your account, then submit a ticket to have the databases imported for you.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  12. You solved my problem I had for ages in less than 10 minutes. Would give this solution a 10/10 rating

  13. Dear sir, madam,

    i don’t know why i cannot import database.

    it is alway send an Error Message as bellow if i create by sql:

    MySQL said:

    #1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation

    another Error if i import database, it as bellow:

    SQL query:

    --
    -- Database: `news`
    --
    CREATE DATABASE IF NOT EXISTS `news` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
    

    MySQL said:

    #1044 - Access denied for user 'esccam5'@'localhost' to database 'news'

    Please guide me to do.

    my customer suggest me to do it as soon as possible.

    thanks.

    Best Regards,

    Duong sokheng

    1. Hello Duong,

      Try to comment out the line: CREATE DATABASE IF NOT EXISTS `news` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

      As the database should already be created via the cPanel, this line is not necessary.

      Kindest Regards,
      Scott M

  14. Hello,

    I tried — in uploading issue , and it uploaded successfully

    but I have only tthe home page working then I have an error :

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


    Apache Server at learnarabics.com Port 80
     
    ——————————————————————————————
    Thank you in advance
    wafaa
  15. I’m still getting the same error. The dash (–) that you say is already there so is it not working? Pls help. Thanks!

    1. Hello Sarla,

      The dashes (–) make that line a comment so that it is not run. However, to import a file, the database already needs to have been created within the cPanel. Have you confirmed that was done already? If so, try removing the line about creating the database entirely and see if that helps.

      Kindest Regards,
      Scott M

  16. Please am new to all this.. am trying to use the phpmyadmin on my cpanel.. but it not giving me the option to create database.. but when i check my settings /Main panel it shows that… “Show create database form” is “DISABLED“..

    please i need help on this!

  17. Thank you Scott for replaying so fast, but I am not sure if I understand use of username. I gave all of the priveledges to the username, I can see in MySQL database that username has all priveledges on chosen database. Is there something that I should maybe uncheck or do I have problem with host, that I can not import it. Do I have to adiionaly sign in username somewhere in phpmyadmin while trying to import, because I don’t see that option…

    At the end I am following a tutorial on the topic, but I ended not going farther.

    I have seen some forums saying that you should or delete in text editor or comment it with “–“, the part on beginning CREATE or in my case DROP.   I tried it all but still nothing

    1. Helo Bojan,

      Thank you for contacting us. As Scott suggested, I would double check the spelling of your username, password, or database name. You can view your database name, and username by following our guide on How to find which users are attached to databases

      For example in your sample it shows:
      ‘bojanarcon’@’localhost’ to database ‘sakila’

      Typically a database and username would include a prefix, for example:
      ‘inmotion_bojanarcon’@’localhost’ to database ‘inmotion_sakila’

      I hope this helps,
      John-Paul

  18. Hi,

    Thanks for the post, but it doesn’t work for me so I need your help
     
    I just started to do some AJAX,PHP and MySQL tutorial from Tuts+ and need to import ‘sakila-schema.sql’ to my database ( FROM HERE https://dev.mysql.com/doc/index-other.html )   , but I ended up having error replay

    SQL query:

    DROP SCHEMA IF EXISTS sakila;

    MySQL said: Documentation
    #1044 – Access denied for user ‘bojanarcon’@’localhost’ to database ‘sakila’

    This is how it looks first few rows of the ‘sakila-schema.sql’

    SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’TRADITIONAL’;

    DROP SCHEMA IF EXISTS sakila;
    CREATE SCHEMA sakila;
    USE sakila;


    — Table structure for table `actor`

    CREATE TABLE actor (
      actor_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
      first_name VARCHAR(45) NOT NULL,
      last_name VARCHAR(45) NOT NULL, …………

    1. Hello Bojan,

      This error is usually due to either the username, password, host, or database name being incorrect. First be sure that all of those credentials are correct. If that passes, you will want to check the user privileges for that user to ensure they have the rights to do everything in the sql file. If it runs across a command it does not have access to run, then it may give this error.

      Kindest Regards,
      Scott M

  19. Hello, I’m using dreamweaver cs 5
    when I’m trying to create a data base using this :
    connect_error) {
    die(“Connection failed: ” . $conn->connect_error);
    }

    // Create database
    $sql = “CREATE DATABASE Facellaneousdatabase”;
    if ($conn->query($sql) === TRUE) {
    echo “Database created successfully”;
    } else {
    echo “Error creating database: ” . $conn->error;
    }

    $conn->close();
    ?>

    it says:
    Error creating database: Access denied for user ”@’localhost’ to database ‘facellaneousdatabase’

    anyone can help me please?

    1. Hello Nirva,

      It appears that the error message you provided reads as: ”@’localhost’ to database ‘facellaneousdatabase’

      It should have a database user name in it, so it would appear as ‘username’@’localhost’. This means that your application does not have a username involved. That is why you are getting the error. You will need to ensure the code is using a database user when connecting.

      Kindest Regards,
      Scott M

  20. here is error message after made the change in the line:

    — Database: `c374739_dictionnaire`

    –CREATE DATABASE IF NOT EXISTS `c374739_dictionnaire` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    –USE `c374739_dictionnaire`;

    Error

    SQL query:


    — Database: `c374739_dictionnaire`

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

    MySQL said:

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--CREATE DATABASE IF NOT EXISTS `c374739_dictionnaire` DEFAULT CHARACTER SET utf' at line 4

    before it was :

    — phpMyAdmin SQL Dump
    — version 4.0.4
    — https://www.phpmyadmin.net

    — Host: localhost
    — Generation Time: Aug 25, 2014 at 11:24 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`;

    I need help!!!!!!!!!!!!   thank you

    Best regard

    1. Hello Kayen,

      As per our previous response, we may not be able to provide a response that requires that you contact a programmer. In this case, you are showing a different error which indicates a SYNTAX error. Typically, in this case, it means that you may have code that is no longer supported by the version of MySQL that you are running. MySQL code is continually updated, so if you are using code that was written for an older version of MySQL, then you will need to update the MySQL code to match the version that you are currently running. Click here to determine the version of MySQL that you are running. You can also visit our document called Finding your MySQL version for the same information.

      If you go to the official MySQL documentation, you will see the documentation for the versions in the left hand column. You will need to look at the syntax and correct it for the version that you are running on your server.

      We do apologize that we cannot give you a DIRECT answer. You will need to work with a programmer if you are unable to update your MySQL code.

      Kindest regards,
      Arnel C.

  21. 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
    — https://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 ;

    1. 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.

  22. 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

  23. 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.

    1. 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

  24. 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!

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

    and how to then connect to database/localhost

    1. 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.

  26. 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.

    1. 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.

  27. 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.

     

     

    1. 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.

    1. 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

    1. 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

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

Was this article helpful? Join the conversation!

Server Madness Sale
Score Big with Savings up to 99% Off

X