Cant connect to to DB using CI4 |
Hi,
I have been using CI3 for couple years. I am installing CI4 as a fresh installation. When i enter my DB credentials on my localhost I keep getting a error message Unable to connect to the database. Below is my config for my database. Any help would be really appreciated. public $default = [ 'DSN' => '', 'hostname' => 'localhost', 'username' => 'root', 'password' => 'root', 'database' => 'online_order', 'DBDriver' => 'MySQLi', 'DBPrefix' => '', 'pConnect' => TRUE, 'DBDebug' => TRUE, 'charset' => 'utf8', 'DBCollat' => 'utf8_general_ci', 'swapPre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'strictOn' => FALSE, 'failover' => [], ];
Is port missing?
PHP Code: 'port' => 3306,
If your port is already 3306 and you're still having the problem, then try changing 'hostname' => 'localhost' to 'hostname' => '127.0.0.1'.
Make sure these values are not overridden with different values by corresponding settings in the .env file. CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface (admin templates include Bootstrap5)
Hi,
I have used the following config but its still not connecting ... public $default = [ 'DSN' => '', 'hostname' => '127.0.0.1', 'username' => 'root', 'password' => 'root', 'database' => 'online_ordering_new', 'DBDriver' => 'MySQLi', 'DBPrefix' => '', 'pConnect' => TRUE, 'DBDebug' => TRUE, 'charset' => 'utf8', 'DBCollat' => 'utf8_general_ci', 'swapPre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'strictOn' => FALSE, 'failover' => [], 'port' => 3309 ];
Try testing it with MySQLi Test
PHP Code: <?php See if that works if not you have a problem in user password or host. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-17-2021, 12:26 PM)InsiteFX Wrote: Try testing it with MySQLi Test It working fine and showing all the tables. Also my table is working fine with my old CI3 . Do you think it has something to do with spark? Because I am using MAMP as my local dev server. So i realized it is because of php spark. When i just go on localhost/codedeniter/public/home it works fine. Any reason why?
For one set the pConnect to false it causes problems.
If that doe's not work post your complete Database.php file so we can look at it. I use xampp and I can connect fine but I do not use spark. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Checkout the following site and use their recommended MySqli error validation when connecting. It is comprehensive.
https://phpdelusions.net/ |
Welcome Guest, Not a member yet? Register Sign In |