# MySQL Database

### Setting up the MySQL Database

1. Log into MySQL as root, providing the password at the prompt  
      
    `mysql -u root -p`
2. Create the database with the command below  
      
    `CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`
3. Create a user/password combination with appropriate permissions for the database (replace moodle, moodleuser and yourpassword with an appropriate database name, username and password)  
      
    `GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'yourpassword';`
4. Flush the privileges  
      
    `flush privileges;`
5. Exit the database  
      
    `exit;`