I updated my install and configure MySQL post on June 2, 2020.

Install MySQL

Install MySQL on Ubuntu.

sudo apt-get update
sudo apt-get install mysql-server -y

Configure MySQL

Enter your details and get a basic configure.sql script. Be nice.

CREATE DATABASE IF NOT EXISTS '{{databasename}}';
CREATE USER IF NOT EXISTS '{{username}}'@'{{hostname}}' IDENTIFIED BY '_not_password_';
ALTER USER '{{username}}'@'{{hostname}}' IDENTIFIED BY '{{password}}';
GRANT ALL PRIVILEGES ON '{{databasename}}'.* TO '{{username}}'@'{{hostname}}';
FLUSH PRIVILEGES;

Once you’re done entering the details, copy and paste into a local configure.sql file.

Note the space at the beginning of the command. This prevents it from being stored in your (bash/zsh/fish) history.

Run the configuration queries. This assumes you’re working on localhost.

 mysql -u [username] -p[password] < configure.sql