Working with MySQL/MariaDB

1 hour
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab, you will install Mysql/MariaDB on a CentOS 7 server. Once that is complete, you will be required to configure the server with the provided data.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install MariaDB/MySQL
  1. Install using the official repo:

    sudo yum install -y mariadb-server
    sudo systemctl start mariadb
    sudo systemctl enable mariadb
    sudo mysql_secure_installation
Create required resources
  1. Log in to the server:

    mysql -u root -p
  2. Then, create the database and the table:

    create database city_data;
    use city_data
    create table city_info(
    LatD int,
    LatM int,
    LatS int,
    NS char,
    LonD int,
    LonM int,
    LonS int,
    EW char,
    City varchar(50),
    State varchar(50)
    ) ;
Bulk insert and validate the data
  1. Copy the cities.csv file into the mysql user’s home directory:

    sudo cp ./data/cities.csv /var/lib/mysql
  2. Perform the bulk insert:

    LOAD DATA INFILE '/var/lib/mysql/cities.csv' INTO table city_info Fields terminated by ',' ENclosed by '"' Lines terminated by 'n' Ignore 1 ROWS;
  3. Validate the data:

    select count(city) from city_info where state='KS';

Additional Resources

Your development team has requested an installation of MariaDB/MySQL on a CentOS7 server.
Once it has been installed and configured, you will be required to create a database named city_data.
In this database, you are to create a table named city_info and then bulk import the data located in /home/cloud_user/data/cities.csv.

Once this is complete, you will need to ensure that the data is present by validating that there are 3 cities in Kansas (KS).

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?