It is very easy to install MySQL database on Ubuntu operating system. This guide will show you how to install a MySQL database using the apt-get command.
Step 1: Update apt-get package manager
Before installing MySQL, you should always ensure that the apt-get package manager is the latest version. Please open a terminal application and execute the following command to update apt-get.
sudo apt-get update
Step 2: Install MySQL using apt-get
In Ubuntu, the MySQL server is provided by the mysql-server package. Execute the following command to install the package:
sudo apt-get install mysql-server
During this process, apt-get will ask you whether you want to install the mysql-server package. Press Enter and wait for the installation process to complete.
Step 3: Run the security script
After installing MySQL, it is recommended that you run the mysql_secure_installation script, which will prompt you to set the root password, delete anonymous users, disable root login to the remote host, etc., Can increase the security of MySQL server. Execute the following command to run the security script.
sudo mysql_secure_installation
During the installation process, please answer all prompt questions. From a security perspective, it is recommended that you set a strong password and delete anonymous users.
Step 4: Start MySQL
To start MySQL, execute the following command:
sudo systemctl start mysql
Step 5: Check MySQL status
To check if MySQL is running, execute the following command:
sudo systemctl status mysql
If MySQL is running, you will see the "active (running)" message.
Step 6: Set MySQL to start automatically
On the Ubuntu operating system, the MySQL server does not start automatically at startup by default. Execute the following command to make MySQL start automatically at startup.
sudo systemctl enable mysql
So far, you have successfully installed and configured the MySQL database on the Ubuntu system!
The above is the detailed content of How to install mysql database on ubuntu. For more information, please follow other related articles on the PHP Chinese website!