This manual is to help you on getting started with

  1. Setting up a MySQL Server
  2. Configuring the Users, Databases and Privileges
  3. Working with tables using CLI
  4. Programming using Python Wrapper

1. Setting up a MySQL Server

Get your Amazon Linux 2 running on a Terminal / Command Prompt / Putty and execute the following

sudo yum update -y

If you see an error mentioning package not found, execute sudo amazon-linux-extras install epel and respond with y to confirm installation of various packages

To install MySQL server, execute the following
sudo yum install mariadb-server -y

Once the installation is complete, execute the following command to start and secure your MySQL server

sudo systemctl start mariadb

sudo mysql_secure_installation

  • Default Password is None, so just press Enter without typing anything
  • Set a new root password when prompted and make sure you remember it
  • You may remove the anonymous users to secure your MySQL server, Disallow remote root logins and remove test databases
  • Finally make sure you reload the privileges so the changes can take effect

Feel free to check if the server is running by executing netstat -lptn and you should be able to the port 3306 open

2. Configuring the Users, Databases and Privileges

Login to the MySQL terminal by executing mysql -u root -p. Enter the password when prompted (This is the same password that you just set in the Step 1)

Basic database commands

3. Working with tables using CLI

Basic database commands

4. Programming using Python Wrapper

If python 3 hasn’t been installed yet, do the same by executing sudo yum install python3 -y

Once Python3 is installed, install the MySQL python wrapper by executing

sudo pip3 install pymysql

Last modified: October 3, 2020

Author

Comments

Write a Reply or Comment

Your email address will not be published.