I have a recently set up VPS with cPanel.
I’ve made a user and created a database, and now I would like to import a database onto it.
However, when I try I get the error message
#1044 – Access denied for user ‘user’@’localhost’ to database ‘database’
I suspect that this can be fixed with WHM, but I do not feel like trial and error just yet.
How would I go about fixing this?
When you import a database using phpMyAdmin, normally you do so by importing a text file with a
.sqlextension. Here is a section of code that may be in a .sql database backup. In your example, the database you are trying to import is named database.When using phpMyAdmin to attempt to import such a file, you will receive an error message similar to:
In this scenario, the cPanel username is
user. Because of cPanel’s database naming conventions, all database names must begin with the cPanel username followed by_. Using this format you can only creat a database nameduser_database.The reason this import failed is because of the following line in the .sql file…
Again, you cannot create a database named
database, however you can create a database nameduser_database.If you change the line that says:
CREATE DATABASEso that it creates:user_databaseinstead ofdatabaseit will again fail with the following message:When using cPanel, databases must be created within the cPanel itself.
Here are the steps to correct thi sissue:
user_databasedatabase within cPanelComment out the
CREATE DATABASEcommand in my .sql fileTo do this, simply change:
CREATE DATABASE database;to
-- CREATE DATABASE database;You are simply adding
dash-dash-spaceto the front of the line to comment it out so that it will not be executed.Log into phpMyAdmin, access the
user_databasedatabase, and then import as normal.