Skip to content

Instantly share code, notes, and snippets.

@cdrani
Last active February 4, 2023 20:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdrani/037763d3524dd23f0a3add18a6e5784d to your computer and use it in GitHub Desktop.
Save cdrani/037763d3524dd23f0a3add18a6e5784d to your computer and use it in GitHub Desktop.
MySQL Setup

Set up and configure our DBMS of choice, MYSQL, to store and manage data. Additionally setup user credentials validation and reset MySQL default users, databases, etc.

sudo apt install -y mysql-server

After installation, it's recommended to purge some insecure default settings and lock down access to the database system. The first thing we should do is set a password for the root password (using mysql_native_password as our default authentication method**)** as by default it has none - a huge security risk.

Now we can finish the configuration using the mysql_secure_installation script. We will be given a chance to update our password based on a VALIDATE PASSWORD PLUGIN to ensure some level of security for all database credentials. I will opt for the MEDIUM level (1) but for a production project I advise the STRONG (2) one.

sudo mysql_secure_installation

The last step is doing a cleanup and resets of the default users, databases, privileges, etc that MySQL has baked in.

Finally, let's test that we as root require a password to access the MySQL console:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment