Home >Database >Mysql Tutorial >Install mysql under linux
In development and operation and maintenance, MySQL is a very commonly used relational database management system. Different from other commercial database software, MySQL is a completely open source software; due to MySQL's own efficiency and stability, many websites, Enterprise-level applications and e-commerce systems will choose to use MySQL as the back-end data storage service. Installing MySQL in the Linux operating system allows us to get a stable, reliable, and efficient relational database system.
This article mainly introduces the steps and key points of installing the MySQL database under the Linux operating system. We will take the Ubuntu operating system as an example to introduce how to install MySQL and solve common problems.
Before installing MySQL, we need to confirm that it has been configured and updated according to the operating system's documentation and requirements. Confirm that the system can access the Internet. If you need to download files during the installation process, you can download them from the corresponding software mirror site. If your system does not have MySQL installed, you can run the following command to ensure that the MySQL server does not start when the system starts.
sudo systemctl disable mysql
Before installing MySQL, you can use the following command to upgrade the software package and system:
sudo apt update sudo apt upgrade
The easiest way to install the MySQL server is to use the command line terminal, Run the following command with root privileges:
sudo apt install mysql-server
Executing this command may take some time to download and install the system's software packages. During the installation process, you will be asked if you want to set a MySQL root password. Enter the set password and confirm the password again. After completing the setup, the output of the installer will be displayed on the terminal. Find the command to start the MySQL service in the output and copy or write it down:
sudo systemctl start mysql sudo systemctl status mysql
If an error message appears, please resolve it based on the output information.
After installing MySQL, we need to set the root password of MySQL. You can use the following command to set the MySQL root password:
sudo mysql_secure_installation
When setting the MySQL root password, you can follow the following steps:
When setting the MySQL root password and password-policy-validator plug-in, just enter the password as prompted in the command. If you want to change the settings for checking password strength, you can modify the password-validator configuration file.
MySQL server starts by default immediately after installation. If you need to restart the service, you can use the following command:
sudo systemctl restart mysql
If you need to stop the service, you can use the following command:
sudo systemctl stop mysql
If you need to check the status of the MySQL service, you can use the following command :
sudo systemctl status mysql
When you need to regenerate or add MySQL users and permissions, or want to apply your new MySQL configuration file, you may need to reload the MySQL configuration. Use the following command to reload the MySQL configuration:
sudo systemctl reload mysql
If you need to access the MySQL server from another computer or server, you need to enable remote access. It should be noted, however, that remote access presents security risks and should only be enabled when necessary. If you want to enable remote access, follow these steps:
sudo mysql -u root -p GRANT ALL ON *.* TO 'your_username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES;
Installing a MySQL database in a Linux environment is not a difficult task, it only requires simple commands Complete installation and setup. However, security and user permissions issues need to be carefully considered during installation and setup. We recommend checking the documentation and community for the latest installation guides and best practices before proceeding with installation and configuration to ensure optimal security and performance of your service.
The above is the detailed content of Install mysql under linux. For more information, please follow other related articles on the PHP Chinese website!