-
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:
Make sure to set the version to 5.7 as otherwise it is easy to run into compatibility issues
### MYSQL #################################################
MYSQL_VERSION=5.7
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 folder, 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 command line 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
Then type
php artisan migrate
This will create a migrations table, and run the migrations that can be found in the _database/migrations_directory inside codehub-mentorships, setting up users, password_resets and failed_jobs tables.
We have no registration set up on the app yet, but if you fetch this branch you can create a first user from the commandline https://github.com/CodeHubOrg/codehub-mentorships/tree/katja/inertia-login
Inside the workspace docker container, run
php artisan make:superuser
(at this stage just a normal user really) This will then print out email -- by default [email protected]
-- and password of the user
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