database creation using codeigniter database dbforge class gives "Access denied for user 'username'@'localhost' to database 'database_name' " Using codeigniter database dbforge class I have created a database and loaded that database as the current database and created tables in localhost WAMP server. But when I uploaded it to the server I am not able to create the database using dbforge class.  

$this-&gt;dbforge-&gt;create_database($database_name)


This command line gave me the following error:

Error No 1044: Access denied for user 'username'@'localhost' to database 'database_name'    


I am using the 'cpanel' hosting provider . 

EDIT1: How we can give permission for a mysql user to create database in cPanel hosting provider...?

EDIT2: The Privileges list of user does not show 'CREATE DATABASE' Privilege in Cpanel. The user is created through cPanel and it have been given all the available privileges, but the CREATE DATABASE privilege is not available in that list in cpanel.
Using C-Panel / WHM, you create databases on a per application basis. Let's say that your c-panel username is john123 and you were installing a blog. You'd do the following:


Go to c-panel -> databases -> and create the database john123_blog
Go to databases -> users and create a user to access it john123_blogu
Add the user to the database, and give them the appropriate permissions


At that point, you can use the dbforge class to create tables within the database. In a shared hosting setup, users are often limited to how many databases they can have, so database creation itself has to go through the automation software (in this case, c-panel).

There's nothing wrong with your code, it's just assuming a non-shared environment.