Databases can store a vast number of records effectively which makes the information simple and easy to find. Other than that, adding or amending new data to the existing one is also relatively simple to do. This article is all about the installation of MySQL on Ubuntu, which is the most extensively used Linux distro in the public cloud with machine learning capability. It’s easy for beginners because it’s built on Debian’s design and structure. It’s designed for enterprise servers, desktops, the cloud, and the IoT.
MySQL is an Oracle-developed relational database management system (RDBMS) focused on structured query language (SQL). Databases consist of collections of assembled data. SQL is a programming language that allows programmers to create, change, and retrieve data from relational databases, as well as manage user access. SQL is used by MySQL databases. Further installation of MySQL is explained in proper steps.
Below are the steps mentioned to install MySQL on your Ubuntu server.
The apt package repository can be used for the installation of MySQL on Ubuntu 20.04. At the time of writing this article, the default version of the MySQL repository for Ubuntu was version 8.0.28.
Before installing, first, you need to update the packages of your server. Run the below-mentioned command to update all packages.
$ sudo apt update |
Run the command mentioned below to complete the installation of the “MYSQL-server” package.
$ sudo apt install mysql-server |
MySQL will be installed but will not require you to create a password or modify any other settings. We’ll deal with this next because it makes your MySQL installation insecure.
To verify its installation, run the below-mentioned command to check its status:
$ systemctl status mysql.service |
You should run the DBMS’s inbuilt security script on the new MySQL installation. For remote root logins and sample users, this script overrides some of the less secure default configurations.
Run the below-mentioned command for security script:
$ sudo mysql_secure_installation |
A series of questions will be asked where you can adjust the security options for MySQL installation. The first step will ask if you want to apply the “password validation” plugin, which may be used to evaluate the strength of new MySQL users’ passwords before approving them.
If you enable the “Validate Password” plugin, the MySQL user you create that validates with a password must use a password that complies with the rules you provide. Passwords must be at least “8 characters” long and comprise a combination of uppercase, lowercase, and numeric letters. Then choose the policy level. After this, setting a password for the root user of MySQL will be asked, regardless of whether you opt to utilize the “Validate Password” Plugin or not. Enter and then confirm the following safe password.
This script will then prompt you to delete the testing database, delete the anonymous user/users, and restrict the root user/users from accessing the local machine. All questions should be answered with a “Y” (yes).
The MySQL client program, installed as a dependency of the MySQL server package, can be used to connect with the MySQL server via the command line.
The root user of MySQL in Ubuntu running MySQL 5.7 (and later versions) is set as default to verify using the “auth socket” plugin rather than a password. The name of the operating system user who launches the MySQL client must match the name of the user of MySQL supplied in the command for this plugin to work.
$ sudo mysql |
The below-mentioned code will be used to create a new user.
$ mysql> CREATE USER ‘USERNAME’@’HOST’ IDENTIFIED BY ‘PASSWORD’ |
Write the below-mentioned code in front of the “MySQL” prompt to create a new user “Linux”, host “localhost” and password “Linux@123”.
$ mysql> CREATE USER ‘linux’@’localhost’ IDENTIFIED BY ‘Linux@123’ |
You can give privileges by writing the code mentioned below.
$ mysql> GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'linux'@'localhost' WITH GRANT OPTION; |
The below-mentioned code will exit MySQL.
$ mysql> exit |
Databases can store a vast number of records effectively. MySQL is a relational DBMS used to store, edit, and delete data. This article is about how to install the MYSQL database on your Ubuntu system (popular Linux distribution). Follow the steps properly for a successful installation.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.
In this article, we will see how to Install Google Cloud BigQuery Python client library…
Nov 15,2024 Wallpaper Contest for Xfce 4.20 open for voting The submission phase for the…
MicroCloud 2.1.0 LTS is now available, expanding the number of Canonical infrastructure solutions with a…
Canonical is thrilled to be joining forces with Dell Technologies at the upcoming Dell Technologies…
In today’s massive private mobile network (PMN) market, one of the most common approaches to…
Welcome to the Ubuntu Weekly Newsletter, Issue 865 for the week of November 3 –…