-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up a MySQL database for the app
(This is again written on the basis that we use Laradock, but should be easy to transfer to other environments)
Below are the configurations for the two .env files. It does not matter what you choose for names (database, user and password), as long as they are the same for both files.
codehub-mentorships/.env:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=mentoring
DB_USERNAME=mentor
DB_PASSWORD=bristol
laradock/.env:
### MYSQL #################################################
MYSQL_VERSION=8.0.21
MYSQL_DATABASE=mentoring
MYSQL_USER=mentor
MYSQL_PASSWORD=bristol
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=root
MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d
Inside the laradock directory, run docker-compose up -d nginx mysql
Inside laradock, run docker-compose exec mysql mysql -u root -p
, then enter your db root password.
This should take you onto the mysql commandline inside the mysql docker container.
Now you can create the database:
mysql> CREATE DATABASE mentoring;
This is all we need to do in this container; \q will take you out of mysql and the container.
Enter the workspace container with docker-compose exec workspace bash
.
Inside the container, you should be in the /var/www
directory
Please note, if you have set up the project previously, you might have to run composer dump-autoload
to make the class for the user seeder available.
Then you can run:
php artisan migrate:fresh --seed
This will create the database tables for the application and create a User that you can use to authenticate in the application.
The login credentials for this test user are:
email: [email protected] password: password
After rebuilding the frontend of the app with npm run dev
or yarn dev
you should be able to use these credentials to log in at localhost/login