Derry Spann | {hostname}

Mysql setup on AWS EC2

  1. Update the environment yum update -y

  2. Install Maria DB server yum install mariadb-server -y

  3. Start Mariadb service systemctl start mariadb

3a. Check database status service mariadb status

3b. Enable mariadb on startup or reboot systemctl enable mariadb && systemctl is-enabled mariadb &&

  1. Configure Mysql credentials Change to root sudo su -

mysql_secure_installation * Go through each step with the following prompts * - setup new root password ( Yes, you will need this to access your database at root level ) Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.

  • remove anonymous user ( Yes, you don't need anyone attempting to access your database other than root or an authorized user ) By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y

  • disallow remote login Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n]

  • remove test database By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n]

  • reset prvilages table Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n]

  • You're Done. All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

Log into mysql cli as root

root > mysql -u root -p

Add remote user with all privileges

mariadb> CREATE USER 'developer'@'%' IDENTIFIED BY 'signchef777!'; mariadb> GRANT ALL PRIVILEGES ON . TO 'developer'@'%'; mariadb> FLUSH PRIVILEGES; mariadb> exit;

mariadb> CREATE USER 'production'@'%' IDENTIFIED BY 'signchef777!'; mariadb> GRANT ONLY create, read, update, delete, index mariadb> FLUSH PRIVILEGES; mariadb> exit;

grant all on .* to ''@'' identified by '<DB_USER_PASSWORD' with grant option;

Log into database and create new DB

Later log into the developer laravel account Edit the DB endpoints to the mysql service