Introduction
MySQL is one of the most utilized open source database platforms globally. It’s available both as a community version (free) and enterprise version (paid) which has more features for enterprise environment.
MySQL is a relational database system with Structure Query Language (SQL) commands [SELECT, CREATE TABLE, UPDATE, DELETE, INSERT, DROP TABLE, e.t.c] for managing relational databases. In this tutorial, we will show how to install MySQL 8.0 Community version which is currently the latest version (and includes powerful features, yet very easy to set up and use). We will then illustrate how to retrieve the mysql root password, alter it and create a database in Ubuntu 22.04 Linux VPS.
Install MySQL 8.0 Server
First, update the repository by running command:
$ sudo apt-get update
Then install the mysql server
$ sudo apt-get install -y mysql-server
Start MySQL Service
At the end of installation start mysql server.
$ sudo systemctl start mysql $ sudo systemctl status mysql
Confirm the mysql version is 8.0
$ mysql --version
Secure the MySQL Installation
$ sudo mysql_secure_installation
Create MySQL Database
Log into mysql server as root.
$ mysql -u root –p
Enter the password for root in the prompt.
Create new database called ‘myfirstdb’.
mysql> CREATE DATABASE myfirstdb;
List all databases in the mysql-server
mysql> SHOW DATABASES;
Once you done with all commands, you can quit the mysql window by using this command:
mysql> quit;
Conclusion
We have now gotten you up and running in the most critical part (i.e. installation of the latest version of MySQL Server and creating a database). The next step is to learn how to run more MySQL commands in order to manipulate the database to your liking. These include creating new mysql users, granting users privileges, creating tables in databases, inserting and updating records in tables, making queries to obtain records from the tables and many other functionalities. You should also consider learning how to backup and restore databases from the command line.