Welcome Guest, Not a member yet? Register   Sign In
Problem with Forge createDatabase

(This post was last modified: 07-30-2021, 04:56 AM by Chroma. Edit Reason: Added possible solution. )

Is there a way of doing this cleanly, so that we can connect to the database server and then create a new database on that database server.

This used to work before. I think, as I just deleted a database from the MySQL server that was only created recently.

This is what I did as a work around, it seems to work, but my be a bit skippy.

My init forge looks like this...

PHP Code:
$forge Database::forge('db_init'); 
Then in the Config/Database.php file I added a new connection...

PHP Code:
 * The db_init dummy database connection.
 * Needed to enable the system to connect to the server,
 * but not to any database, this enable the creation of a
 * new database.
 * @var array
public $db_init = [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'user',
'password' => 'pass',
'database' => '',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,

You will of course need to set the username and password fields correctly.

Messages In This Thread
RE: Problem with Forge createDatabase - by Chroma - 07-30-2021, 04:50 AM

Theme © iAndrew 2016 - Forum software by © MyBB