How to install MySQL on Ubuntu?

To install MySQL in Ubuntu, you can follow these steps:

First, open a terminal and run the following command to update the package list:

sudo apt update

Next, run the following command to install the MySQL server:

sudo apt install mysql-server

You may be asked to confirm the download and installation. If so, press y, and press Enter.

During the installation process, you will be asked to set a password for the MySQL root user. Make sure to choose a strong and secure password.

After installing MySQL, the MySQL service should start automatically. You can verify it with the following command:

sudo systemctl status mysql

If the MySQL service is running, you should see it in the output active (running).

After the installation is complete, it is recommended to run mysql_secure_installationthe command to increase the security of the MySQL installation. This script will let you change root password, disable root remote login, remove anonymous user account and test database.

sudo mysql_secure_installation

Just follow the prompts.

Finally, you can log in to MySQL with the following command:

sudo mysql -u root -p

Then enter the password of the root user you set.

The above are the basic steps to install MySQL in Ubuntu. If you encounter any problems during the installation process, you may need to consult more specific documentation or refer to some online tutorials.

Note: Pay attention to your MySQL version during use, because there may be some differences between different versions of MySQL.

Guess you like

Origin blog.csdn.net/m0_57236802/article/details/131292413