MySQL is a widely used relational database management system. This manual will help you install and backup the MySQL database server on your Ubuntu 20.04 LTS system.
Requirements
Before proceeding with the installation of MySQL under Ubuntu 20.04
- Login to Ubuntu as a sudo-privileged user
- For newly installed systems required to complete the initial server configuration
Step 1 – Install MySQL Server
MySQL Server 8.0 packages are available in standard repositories on Ubuntu 20.04. After logging on to the server, update the apt cache and run the installation packages. To install the MySQL server, type
install sudo apt update
sudo apt mysql server
Wait until the package manager has completed the installation.
After the installation is complete, the MySQL service starts automatically. To check the nature of the service:
sudo systemctl mysql status
Step 2 – Protection of MySQL Server
At this stage, the MySQL server has not yet been backed up. You can switch to the root user of your system and connect to the MySQL server. He won’t ask for a password.
So this is where we need to back up the MySQL server. The packages provide a script for this. Execute the following command to initially configure your MySQL server. You will see that the script requests more parameters than in previous versions of MySQL, such as the validation policy for passwords, etc. You will also see that the script requests more parameters than in previous versions of MySQL.
sudo mysql_safe_installation
Follow the on-screen instructions to complete the wizard. All user data is highlighted in the wizard below. This creates a password for the root user, deletes the test database and the user to secure the database server.
Deployment of a secure MySQL server.
Log in to MySQL with an empty password.
The VALID PASSWORD COMPONENT can be used to test
passwords and improve security. It checks the strength of password
and allows users to set only passwords strong enough for
. Do you want to configure the VALIDATE PASSWORD component?
Press y|Y for Yes, another key for No: y.
There are three levels of password verification guidelines:
MEDIUM length >= 8, numeric, mixed and special characters
HIGH length >= 8, numeric, mixed, special characters and dictionary file
Fill in 0 = low, 1 = average and 2 = advanced: 2
Set the master password here.
New password :
Enter a new password:
Password strength estimation : 100
Do you want to continue with the given password? (Click y|Y for Yes, any other key for No): y
By default, the MySQL installation has an anonymous user.
allows anyone to login to MySQL without creating a
account. This is only for
tests and also to facilitate installation.
You must remove these before you can switch to a production environment
.
Delete anonymous users? (Press y|Y for Yes, any other No key): y
Success.
Normally the root should only be able to connect to a local spirit
. This ensures that nobody can guess the root password
of the network.
Denying remote access to the root? (Press y|Y for Yes, any other No key): y
Success.
By default MySQL comes with a database called test, which is accessible to everyone
. It is also for test purposes only,
, and must be disposed of before being transferred to a
production environment.
Are you removing the test database and access to it? (Press y|Y for Yes, any other key for No): y
– Reset the test database …
Good luck
– Delete authorizations in the test database .
Good luck.
Reloading the privilege tables ensures that all previously made changes to
take effect immediately.
Are you restarting the permission signs now? (Press y|Y for Yes, any other No key): y
Success.
Let’s go, let’s go, let’s go, let’s go!
Step 3 – MySQL Service Management
The MySQL service is managed by the system service manager You can follow the standard systemctl commands for managing the database service on the command line. Here are some commonly used commands to control the service:
To stop the MySQL service, type
sudo systemctl stop mysql
To start the MySQL service, type
sudo systemctl start mysql
Stop, then start the MySQL service, enter:
restart sudo systemctl mysql
To view the status of the MySQL service, type
sudo systemctl mysql status
Step 4 – Connecting the MySQL Server
You have successfully installed and secured the MySQL database server on your Ubuntu 20.04 system. Now connect to the database server on the command line with the following command.
mysql -u Carrot -p
Enter the password of the MySQL root user to log in:
Enter the password:
Welcome to the MySQL Monitor. Teams end on; or g.
Your MySQL connection ID is 20
Server version: 8.0.19-0ubuntu5 (Ubuntu).
Copyright c) 2000, 2020, Oracle and/or its partners. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliated companies
. Other names may be trademarks of their respective owners of
.
Enter help or h for reference. Enter c to delete the current data input operator.
mysql>
Step 5 – Create a MySQL user and database
How to connect to the MySQL server from the command line? Your database server is available for your data storage applications.
It is advisable to create a separate database user to connect the database via the application. Use the following commands to create a database on MySQL. Then create a user and assign permissions in the database.
CREATE A MIDB DATABASE;
Create the user [email protected], IDENTIFIED by Pa$$$w0rd ;
GUARANTEE EVERYTHING to mydb.* to ‘myuser’@’localhost
FORFEITED PRIVILEGES
CREATE A MIDB DATABASE;
Create the user [email protected], IDENTIFIED by Pa$$$w0rd ; GUARANTEE EVERYTHING to mydb.* to ‘myuser’@’localhost FORFEITED PRIVILEGES |
Conclusion
This tutorial helps you to install MySQL server on an Ubuntu system. It also contains instructions for backing up the database server.