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.
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:
- Login to your cPanel and click on ‘MySQL Databases’.
- 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).
- Open the sql database file that you are using for importing (e.g. ‘localhost.sql‘) in a text editor such as notepad.
- Search for the text “CREATE DATABASE”
- Delete this line containing the create database command.
- 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’.
- 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;
Example of the sql database file after modifying
CREATE DATABASE `applewoo_applewood` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
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.
Comments (60 responses)
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. 🙂
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!
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!
It’s an easy fix!!
I also kept getting the error: “#1044 – Access denied for user ‘[email protected]%’ 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!
Thank you!!! It worked. It’s rare I see an article helping so many people for four years straight. Thanks again. -Frederico
Thanks, you saved my day
I have no idea about sql database management any this tutorial helped me to bring back my old wordpress website.
You! Are! Awesome! Wow that was easy. Thanks 100x
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!
Absolutely brilliantly simple and works like a dream.
saved my ### man thanks!
Thank you thank you! I love you and I want to have your babies
Thank you so much, you help me alot to get my website back 🙂
Thank you sooo much this was exactly what I needed!
That worked for me, thanks for that.
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.
OMG Thank you thank you thank you. I was SO stuck on why this didn’t work and you saved me.
@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.
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.
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.
omg thank you for this sexy article.
Thanks a bunch for this. Awesome site BTY!
@Sourabh, If you do not have ‘root’ access to the server, ask your host to do this for you.
thanx for info but im gettin this on importing..plz help me to fix it.
— Database: ` b6_8637033_wordpress`
USE ` b6_8637033_wordpress` ;
#1044 – Access denied for user ‘b6_8637033’@’%’ to database ‘ b6_8637033_wordpress’
That’s one of the best and easy to understand tips I have seen in regards to using phpMyAdmin.
You could be a professor 🙂
That helped me a lot. thanks man.
I love the way you explain things, best practical article on the subject.
thanks a lot!!! tha only solution that I found that works. simple and clear 😀
Thank you! Worked like a dream!
I have spent most of the afternoon trying to figure this out! Yours was the only solution that helped – thanks!
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.
thanks man great post ,it helped me a lot
thank you X10000
I’ve lost 2 days until I’ve stumbled upon your explanation. Great !
Freakin life saver! Cheers.
I coudl give you a hug right now, man! I love you!
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!
Wow. That just SAVED ME. Really appreciate it. I was calling friends, begging the internets to help me.
You Rock! Thank you!
Thank you so much for putting this info up,so very grateful.
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
This is just what I needed to know. So glad I found your blog because I was ready to pull my hair out!
You’re a genius :-).
Thanks a lot for this handy tip, I spent hours trying to get this to work before seeing your post.
Thank you thank you! I love you and I want to have your babies
@Roady, what charset are you using?
I took the backup of my database of wordpress though the cpanel -> backup > mysql . When I open it, The text is not in english and in some other weird language. Any thing I can do with this file to get my database back up?
@abbie, this should be easy.. just use the database of the existing blog and run the SQL commands using phpMyAdmin to add the data of the old blog to this new one.
1. Back up the SQL file of your old blog using phpMyAdmin.
2. open the recently downloaded backup SQL file and change the line where it says create database to use the database name of the new blog.
3. Execute the content of the SQL file in the phpMyAdmin of your new blog so it inserts all the entries to this database.
Thanks for sharing this info.
So.. we have to make a new database. What if I want to import a downloaded sql from an old blog to an existing new blog that has had posts and comments already, so that the (different) posts and comments in the old blog inserted into the new blog?
Any suggest would be highly appreciated. Thx..
Exactly what I was looking for. I was transferring my blog and I got the error when importing the SQL database. Glad to have found this post!
@Gina I am glad that the explanation solved your database import issue. I was terrified when I was getting errors trying to import my wordpress database from my old hosting to the new hosting using phpMyAdmin.
Thank you, thank you, thank you. Just what i needed, best explanation possible.