I am using Laravel, and I have already configured .env file. When I make migration and I migrate, it affects the database, but when I try to read from same database I get th
if its a new instalation or new upgrade for wampserver or xampp, You need to include your port into connection,
Because the default MySQL Port is 3306,
But mariadb comes as default on default (3306) port so, when you try to connect MySQL its redirecting to mariadb.
You need to correct your port it might be 3306 or 3307 or 3308 and use ip instead of localhost. your final codes:
$host = '127.0.0.1';
$db = 'test';
$user = 'root';
$pass = '';
$port = '3308';
$charset = 'utf8mb4';
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
try {
$mysqli = mysqli_connect($host, $user, $pass, $port, $db);
mysqli_set_charset($mysqli, $charset);
} catch (\mysqli_sql_exception $e) {
throw new \mysqli_sql_exception($e->getMessage(), $e->getCode());
}
Solved question here
For pdo and docker :
See these answers
You have to set the right permissions:
$ mysql -u root -p
$ <your-password>
$ use mysql
$ GRANT ALL ON *.* to 'homestead'@'localhost' IDENTIFIED BY '<your-password>';
$ FLUSH PRIVILEGES;