Laravel 11: How to Change the Default SQLite to MySQL
In Laravel 11, SQLite is set as the default database for the local environment. However, if you prefer to use MySQL, you can easily change the configuration.
Using Laravel Installer
When you create a new Laravel project using Laravel Installer (version 5.1 or later), you have the option to choose the database your application will use. If you select MySQL, the installer automatically changes the DB_CONNECTION
environment value to mysql
and sets the other relevant database parameters.
Default SQLite Configuration
If you don't use the Laravel Installer, the default database configuration will be SQLite. In this case, the the .env
file will have the DB_CONNECTION
set to sqlite
, with the MySQL-related parameters commented out, like this:
Manually Switching to MySQL
If your project is using the default SQLite setup and you want to switch to MySQL, you’ll need to modify the .env
file manually:
-
Set the
DB_CONNECTION
tomysql
. -
Uncomment the MySQL-related parameters and provide the appropriate values for your database configuration.
Your the .env
file should look like this:
Once you've made these changes, your Laravel application will be configured to use MySQL instead of SQLite.