Monday, March 1, 2021

Connecting To Mysql 8

I actually instanced the MySQL 8 database I'm planning to use via RDS back in early November. The security groups for the DB are setup such that it cannot be accessed by anything outside of my VPC. Both the http server and the bastion host can connect to it, but any manual SQL should only be executed from the bastion host.

To get this all up and running there were a couple of things I needed to do.

  1. Update the service ini file so that it contains the correct credentials for connecting to the database.
  2. Install the myself command line shell on the bastion host so that I can manually execute SQL.
  3. Execute said SQL in order to create the necessary schema, user and table.

The first step was easy. I did run into a problem when I attempted to setup an alias for the DB host via the /etc/hosts file. For some reason that didn't work. Some quick googling suggested I check my file permissions, but as expected, the file is globally readable. Oh well. I just ditched that idea and moved on.

The second step was . . . more complicated. Amazon linux extras doesn't come with any mysql topics. So, I had to do some research to find a yum repository that contained what I needed and then figure out (as a yum n00b) how to actually make it so that the repository in question can be accessed.

First I found some AWS documentation that led me to believe that Amazon Linux 2 is roughly compatible with RHEL 7.

Then I found some mysql documentation that seemed to imply that if I downloaded and installed the correct rpm package, I'd be able to access a yum repository for MySQL software that's compatible with RHEL 7.

Once I did those two things, in theory I'd be able to find and install a version of the mysql client for MySQL 8 that would work on my bastion host.

And that turned out to be the case.

After that, I ran the SQL to setup the schema, user and table and VOILA my new API is fully functional (such as it is).

It doesn't do much yet, but I'll be able to use it to develop the foundation of the client application.

No comments:

Post a Comment