CodeIgniter4: CodeIgniter\Database\Exceptions\DatabaseException #8 Unable to connect to the database.
CI_ENVIRONMENT = development
app.baseURL = 'http://localhost:8080/'
database.default.hostname = localhost
database.default.database = ci4
database.default.username = root
database.default.password =
database.default.DBDriver = MySQLi
Controller Komik.php
<?php namespace App\Controllers;
class Komik extends BaseController
{
public function index()
{
$data = [
'judul' => 'Daftar Komik'
];
// cara konek db tanpa model
$db = \Config\Database::connect();
$komik = $db->query("SELECT * FROM komik");
dd($komik);
return view('komik/index', $data);
}
}
My Model
<?php
namespace App\Models;
use CodeIgniter\Model;
class KomikModel extends Model {
protected $table = 'komik';
protected $useTimestamps = true;
}
i user xampp
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 25 (6 by maintainers)
Many times replacing
localhost
with127.0.0.1
will get your database working.Here’s your error message. It seems you are using the
MySQLi
driver but your PHP installation hasmysqli
extension not installed or activated. In your php.ini, you can remove the semicolon in; extension = mysqli
Thanks All… it work in my linux
sudo apt-get install php-mysql
It works man, thanks buddy.
Enable php mysqli Extension from php.ini file in php folder
;extension=mysqli
just remove;
like thisextension=mysqli
it’s work for me. Thank You.
My database is remote. With CI3 it works without problems. I’ve setup a new CI4 installation today, but DB-connection fails.
I have all my database info in .env file instead of Database.php, i am using Linux(Kali) and xampp server