This is option for you to choose either MySQL or MariaDB (Previous page)
*The next component of the LEMP Stack on Ubuntu 23.10 is MySQL.
Let’s begin by updating the repository and installing the MySQL package using apt.
sudo apt update && sudo apt install mysql-server
Press Y and ENTER to continue the installation MySQL package.
sudo mysql_secure_installation
You will be prompted with a question asking if you want to configure the VALIDATE PASSWORD PLUGIN
Note: Enabling this feature is something of a judgment call. If enabled, passwords which don’t match the specified criteria will be rejected by MySQL with an error. It is safe to leave validation disabled, but you should always use strong, unique passwords for database credentials.
Answer Y for yes, or anything else to continue without enabling.
If you answer “yes”, you’ll be asked to select a level of password validation. Keep in mind that if you enter 2 for the strongest level, you will receive errors when attempting to set any password that does not contain numbers, upper and lowercase letters, and special characters.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) :
Press Y and ENTER to continue
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
Press Y and ENTER to continue
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for
Yes, any other key for No) :
Press Y and ENTER to continue
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
Press Y and ENTER. All done!
When you’re finished, test if you’re able to log in to the MySQL console:
sudo mysql
This will connect to the MySQL server as the administrative database user root, which is inferred by the use of sudo when running this command. You should receive the following output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.36-0ubuntu0.23.10.1 (Ubuntu)
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
To exit the MySQL console, write the following:
exit
Test MySQL
sudo systemctl status mysql
If running, you will see a green Active status like below.
â—Ź mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Sun 2024-02-04 05:48:19 UTC; 13min ago
Process: 4166 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4174 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 1101)
Memory: 356.2M
CPU: 6.473s
CGroup: /system.slice/mysql.service
└─4174 /usr/sbin/mysqld
You may to type CTRL+C and hit ENTER or Q to exit the service status.
You've completed this section, now your website already integrates with MySQL.
This section was received a latest update on February 4, 2024.