How to Install MYSQL 8.0 and Create a Database on an Ubuntu 22.04 Linux VPS | HostAdvice

How to Install MYSQL 8.0 and Create a Database on an Ubuntu 22.04 Linux VPS

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.

Note
Special Note: before installing MySQL on your server we recommend that you consider if you have the right hosting service. Hosting Services that specialize in MySQL database hosting (such as A2hosting) will be able to provide better support on MySQL related topics. Visit Hostadvice’s reviews for the best MySQL hosting services.

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.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top