This project is organised using the DrWatson.jl
package (see here). To reproduce the project in full, do the following:
- Clone this repository and run the following in
julia
with the path to this project (activate the package manager using]
):julia> cd("path/to/this/project") pkg> activate . pkg> instantiate
- Install MySQL and set up a user with read/write privileges.
- Fill out
./src/database_connection.csv
with your database details. Use./src/user_database_connection.csv
as a template.
- Install MySQL for your system.
- Start the mysql service.
- Set a root password (best practice) using
mysqladmin -u root password
. It will then ask you to enter and then confirm your password. - Run mysql in your terminal as root using
mysql -u root -p
. - Create a user by running the line below. Remember to change the username, host, and password, and store them in a copy of the
user_database_connection.csv
file, renamed to bedatabase_connection.csv
(this will be gitignored).
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
- Grant privileges to this user. The below code grants all privileges on the user. Note that you should only do this for a local database. Replace
ALL
with a comma-delimited list of privileges (e.g.,CREATE
,ALTER
,DROP
) that you want to grant. See here for a full list of privileges. You will need at leastALTER, CREATE, DELETE, DROP, INSERT, SELECT, UPDATE
. Note thatWITH GRANT OPTION
also grants the privilege to grant other users with this user's privileges.
GRANT ALL ON *.* TO 'username'@'host' WITH GRANT OPTION;
- Run
FLUSH PRIVILEGES
to reload grant tables and put privileges into effect. - Verify the privileges of the user by running:
SHOW GRANTS FOR 'username'@'host';
- Exit root with
exit
and then log into your new user withmysql -u username -p
in the terminal.
Run CREATE DATABASE databasename;
in root (or in your user if it has the right privileges) and store the databasename in database_connection.csv
.
It is also handy to have MySQL Workbench for easy data inspection.