How to import WordPress SQL database backup file without having ‘create new database’ privileges in phpMyAdmin

In this article I have explained how you can import your WordPress SQL database backup file even when you do not have the ‘create new database’ privilege in phpMyAdmin. This is particularly useful when you are trying to import the SQL database as part of transferring your site from one host (old-host.com) to another host (new-host.com) and your new host doesn’t have the ‘Create new database’ privilege in phpMyAdmin.

In your phpMyAdmin page check for the ‘create new database’ privilege. If the privilege settings looks like the example shown below then your database import following the normal method is going to fail as it will try to create a database and you don’t have permission to do that.

create new database no privilege

No privilege to create new database

You will get the following error when trying to import the database file:

#1044 – Access denied for user ‘username’@'localhost’ to database ‘database_name’

To get around this problem and to complete importing your database to your new host do the following:

  1. Login to your cPanel and click on ‘MySQL Databases’.
  2. Create a new database with your preferred name (I am going to use the name ‘newDB‘ for easy reference. You should have privilege to create a new database through this MySQL Database panel even though you don’t have privilege to create new database through phpMyAdmin).
  3. Open the sql database file that you are using for importing (e.g. ‘localhost.sql‘) in a text editor such as notepad.
  4. Search for the text “CREATE DATABASE”
  5. Delete this line containing the create database command.
  6. In the next line change the database name (tips_db in this case) to the newly created database (newDB) in step2 after the word ‘USE’.
  7. Now use the import wizard from phpMyAdmin to import the database and it will use the already created database to import all the tables without any problem.

Example of the sql database file before modifying


– Database: `tips_db`

CREATE DATABASE `
tips_db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `
tips_db`;

Example of the sql database file after modifying

CREATE DATABASE `applewoo_applewood` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `
newDB`;

Note: Beth pointed out the following in the comment section below which is good to remember:

You have to make sure that you do a search for "CREATE DATABASE" to delete it and make the change to the "USE tips_db" Line in ALL the places it appears.

What to do if you can’t do the above trick?

You could request your web hosting provider to add database creation privilege to your phpMyAdmin.

Also check out the following two tutorials which should be very helpful:

Hope this will help anyone having a similar problem. Feel free to share your thoughts by leaving comments in the comment area below.

Found this resource interesting? Subscribe to Tips and Tricks HQ

email icon rss feed icon twitter icon google plus icon

Comments (61 responses)

  1. Cy says:

    Wow! I have been struggling with this for hours..
    thanks so much for such useful post.

  2. KJ says:

    Thanks so much for your help! Learning here, tried a bunch of other things, but this solved the problem!

  3. Kei says:

    Thank you so much!! I think WordPress should have this article on their site as well.

  4. Danny says:

    Thank U! That was a big help.
    Many many thanks.

  5. John says:

    Worked perfectly. Thank you so much

  6. admin says:

    @Sherry, What exact error do you get when you try to import the database content?

  7. Sherry says:

    Hi Admin.
    I am still getting the same error .. I got the backup of my complete database including information schema. so when i import the database i got same error. what i have to do please help me. As I did not understand the above trick properly.
    Thanks, waiting for your response

  8. Fazil Ali says:

    Thank You So Much for your solution. Actually its was an error which i am facing first time when importing the WP tables to new database. and I have spent my time too by checking for a solution. But you saved my Time. Thank You. :-)

  9. Robert says:

    Thank you so much for this solution – customer support and a bunch of other google searches were not helpful, as no one pointed out the need to delete the “CREATE DATABASE” line. Worked like a charm – thank you!

  10. kelskc says:

    THANK YOU!! I have been searching everywhere for this solution (not knowing it was this) and not only did it work you made it so easy… you are amazing!

  11. Beth olson says:

    @Sourabh
    It’s an easy fix!!

    I also kept getting the error: “#1044 – Access denied for user ‘b6_8637033@%’ to database ‘b6_8637033_wordpress’

    You have to make sure that you do a search for “CREATE DATABASE” to delete it and make the change to the “USE tips_db” Line in ALL the places it appears. I realized that I was getting that error because I was only changing that information in one place but it was actually occurring in TWO places in the code.
    hope that helps!

  12. Thank you!!! It worked. It’s rare I see an article helping so many people for four years straight. Thanks again. -Frederico

  13. Josh says:

    Thanks, you saved my day

  14. Arup Ghosh says:

    I have no idea about sql database management any this tutorial helped me to bring back my old wordpress website.

  15. Mike says:

    You! Are! Awesome! Wow that was easy. Thanks 100x

  16. Jinny says:

    Thank you for this. I’ve been trying to figure this out for ages and stumbled upon your very helpful article. Managed to import successfully at last!

  17. John says:

    Absolutely brilliantly simple and works like a dream.

    Thanks
    John

  18. Ronnie says:

    Thanks alot…

  19. david d says:

    saved my ### man thanks!

  20. pulau tidung says:

    Thank you thank you! I love you and I want to have your babies

  21. Navneet Singh says:

    Thank you so much, you help me alot to get my website back :)

  22. Rabah Rahil says:

    Thank you sooo much this was exactly what I needed!

  23. beachmatt says:

    That worked for me, thanks for that.

  24. Laura B. says:

    Thank you so much! I had never had this error before and it happened today. All the other answers I found did not work (and didn’t make sense).

    Thank you for an easy to understand and effective solution.

  25. Eric W. says:

    OMG Thank you thank you thank you. I was SO stuck on why this didn’t work and you saved me.

  26. admin says:

    @Starfall, as long as it is backing up your SQL database, it is essentially the same thing. When you backup from your cPanel, you just get more control over the backup operation.

  27. starfall says:

    What’s the difference between having backup in cpanel database and through backend database? Sorry but im not that expert much about wordpress backend. thanks in advance.

  28. Martin says:

    Hi, I’ve found another solution that works too:

    1. In phpMyAdmin select your database first – you can see listing of all tables
    2. Click the Export tab and there select all tables to export, and export as usual

    Exported file then doesn’t contain any ‘create database’ queries, so you don’t need to remove these lines.

  29. Fritz says:

    omg thank you for this sexy article.

  30. Lowell says:

    Thanks a bunch for this. Awesome site BTY!

  31. admin says:

    @Sourabh, If you do not have ‘root’ access to the server, ask your host to do this for you.

  32. Sourabh says:

    thanx for info but im gettin this on importing..plz help me to fix it.

    SQL query:


    – Database: ` b6_8637033_wordpress`

    USE ` b6_8637033_wordpress` ;

    MySQL said:

    #1044 – Access denied for user ‘b6_8637033′@’%’ to database ‘ b6_8637033_wordpress’

  33. Doc Holiday says:

    That’s one of the best and easy to understand tips I have seen in regards to using phpMyAdmin.

    You could be a professor :)

  34. That helped me a lot. thanks man.
    I love the way you explain things, best practical article on the subject.

  35. sebastian says:

    thanks a lot!!! tha only solution that I found that works. simple and clear :D

  36. Ken says:

    Thank you! Worked like a dream!

  37. Laurie says:

    I have spent most of the afternoon trying to figure this out! Yours was the only solution that helped – thanks!

  38. Michelle says:

    Thank you so much! Your a life saver. I was moving the company blog from a sub to the main level and ran into that issue. I looked everywhere and your tutorial was the only one that helped. Thanks again.

  39. Rahul says:

    thanks man great post ,it helped me a lot
    thank you X10000

  40. Fran says:

    Thanks !
    I’ve lost 2 days until I’ve stumbled upon your explanation. Great !

  41. Joel C says:

    Freakin life saver! Cheers.

  42. JP Caparas says:

    I coudl give you a hug right now, man! I love you!

  43. Will Quick says:

    Oh my God, I LOVE you! Thank you SO SO much! I’ve been struggling with this for hours. I’m trying to move a clients WordPress from one hosting account to another and these error messages were driving me INSANE. You have just saved my life and my sanity.

    Honestly, I can’t thank you enough, I’m absolutely overjoyed, haha!

    Thanks again,

    Will

  44. Casey says:

    Wow. That just SAVED ME. Really appreciate it. I was calling friends, begging the internets to help me.

  45. Sara says:

    You Rock! Thank you!

  46. Gordon says:

    Thank you so much for putting this info up,so very grateful.

  47. Nagashiko says:

    This post is very helpful for people like me who doesn’t know that much about IT stuff. The instructions were easy to follow! Thanks so much for the info! =D

  48. Good post. But, im still confusing about this! Maybe i must try this again. Thanks!

  49. This is just what I needed to know. So glad I found your blog because I was ready to pull my hair out!

  50. Nedbenj says:

    You’re a genius :-).

    Thanks a lot for this handy tip, I spent hours trying to get this to work before seeing your post.

Speak Your Mind

*