CodeIgniter Forums
Creating a new database is not working at server in codeigniter 3 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Creating a new database is not working at server in codeigniter 3 (/showthread.php?tid=81883)

Pages: 1 2 3


Creating a new database is not working at server in codeigniter 3 - webdeveloper011 - 05-14-2022

Hello everyone.
I have a accounting management project where I need to store some specific data to a new database. I am fetching a issue when I am going to create a new database in server. It is working fine in local. As this project is made with Codeigniter 3, I am using codeigniter dbforge() library to create new database.

I have made this following this documentation of codeigniter 3.
https://codeigniter.com/userguide3/database/forge.html#database-forge-class

But when I run this code, I get this error message.
Error Number: 1044
Access denied for user 'shohowqj_testing_usr'@localhost to database 'shohoz_hishab_backup_2022'
CREATE DATABASE shohoz_hishab_backup_2022 CHARACTER SET utf8 COLLATE utf8_general_ci

Filename: modules/yearly_closing/controllers/Yearly_closing.php
Line Number: 68

Anybody please help me how to fix it.
Thank you


RE: Creating a new database is not working at server in codeigniter 3 - InsiteFX - 05-14-2022

Whats it say on line number 68?

You need to show your code so that we can help you.


RE: Creating a new database is not working at server in codeigniter 3 - webdeveloper011 - 05-15-2022

This is the code at that line number 68

if (!$this->dbutil->database_exists($newDb)){
$this->dbforge->create_database($newDb);
}


RE: Creating a new database is not working at server in codeigniter 3 - JustJohnQ - 05-15-2022

First guess is that the db user on the server doesn't have privileges to create a new database. It could be a hosting/server limitation.
Can you create a (temp) database with the user credentials in phpmyadmin or some other tool on the server?


RE: Creating a new database is not working at server in codeigniter 3 - webdeveloper011 - 05-17-2022

@JustJohnQ
I am using cpanel and it is shared server. I also think there is a permission issue. But I gave the full permission of the user. I am not sure what do I do next?

You can see. I have posted this question on stackoverflow
https://stackoverflow.com/questions/72237844/creating-a-new-database-is-not-working-at-server-in-codeigniter-3

Please advise if you have any solution of that.
Thank you


RE: Creating a new database is not working at server in codeigniter 3 - JustJohnQ - 05-17-2022

As asked before:
Can you create a (temp) database with the user credentials in phpmyadmin or some other tool on the server?
I am pretty sure you don't have permissions to create and use more than one database on your server.


RE: Creating a new database is not working at server in codeigniter 3 - webdeveloper011 - 05-17-2022

Hi
I did not create temp database with the user credentials. But I created a main database with this user from cpanel.
But as you have confirm that it has permission issue, can you please let me know how to fix the issue?
I think you have seen that I have given the full user privileges.
Thank you


RE: Creating a new database is not working at server in codeigniter 3 - JustJohnQ - 05-17-2022

The problem might be that your hosting party doesn't allow you to create more than one database.
Hence, with user credentials, try to create a temp database.


RE: Creating a new database is not working at server in codeigniter 3 - webdeveloper011 - 05-17-2022

@JustJohnQ
OK, Can you please let me know how to create temp database with that user crendentials? do you have any document for that?
And how can I allow the user to create database from cpanel? I have only cpanel details.
Thank you


RE: Creating a new database is not working at server in codeigniter 3 - InsiteFX - 05-18-2022

You never want to let a user have control of your CPanel.

Try to create a database using pure MySQLi and see if it works.

You may need to supply a username and password on the creation of the database.