Following are some database connection possibilities. It's not mandatory to use one of them but given for demo purpose.
Copy file .env.example
, and change its name to .env
. Then in file .env
complete this database configuration:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
Create a database in database folder.
#create database
touch database/database.sqlite
Copy file .env.example
, and change its name to .env
. Then in file .env
replace this database configuration:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
To this:
DB_CONNECTION=sqlite
DB_DATABASE=/path_to_your_project/database/database.sqlite
$ sudo -u postgres createuser --interactive
enter name of role to add: laravel
shall the new role be a superuser (y/n) n
shall the new role be allowed to create database (y/n) n
shall the new role be allowed to create more new roles (y/n) n
$ sudo -u postgres psql
postgres= ALTER USER laravel WITH ENCRYPTED PASSWORD 'password';
postgres= \q
sudo -u postgres createdb laravel
.env.example
, and change its name to .env
. Then in file .env
replace this database configuration:DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=password