Its easy to setup whatever database you want to use for your project.
You can choose between SQLite, MySQL and PostgreSQL.
For setting up SQLite you need to do two simple steps:
touch database/database.sqlite
in the terminalDB_CONNECTION=sqlite
in .env
and delete the other database variables (all DB_
variables)This works because Laravel uses the database/database.sqlite
file by default. If you want to use a different file, you can update the DB_DATABASE
variable in the .env
file.
First of all you need to create the new MySQL database:
mysql -u root -p
in the terminalCREATE DATABASE your_db_name;
Then you need to update the .env
file with the following variables:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_db_name
DB_USERNAME=your_db_username
DB_PASSWORD=your_db_password
Create the new PostgreSQL database
psql -u <your_db_username>
in the terminalCREATE DATABASE your_db_name;
After creating the DB update the .env
file with the following variables:
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=your_db_name
DB_USERNAME=your_db_username
DB_PASSWORD=your_db_password