CentOS 7 is a very popular Linux operating system, and MySQL is one of the most commonly used database management systems in web development. In this article, we will explain how to install MySQL database on CentOS 7.
Step 1: Install the MySQL software package
Before installing the MySQL database, we need to ensure that the MySQL software package has been installed in our operating system. We can check whether the MySQL package has been installed by using the following command:
rpm -qa | grep mysql
If you have installed the MySQL package, the installed version number will be displayed. If it is not installed, you can use the following command to install the MySQL package:
sudo yum install mysql-server
Step 2: Start the MySQL service
After installing the MySQL package, we need to start the MySQL service. You can use the following command to start the MySQL service:
sudo systemctl start mysqld.service
If you want to automatically start the MySQL service when the system starts, you can use the following command to set the MySQL service to start automatically:
sudo systemctl enable mysqld.service
Step 3 :Set the MySQL root user password
After installing MySQL, you need to set the password of the MySQL root user. You can set the MySQL root user password with the following command:
sudo mysql_secure_installation
This command will prompt you for the database administrator password. By default, in the initial installation, the password is blank.
You will then be asked to set the database administrator password. It is recommended that you use a strong password. Password must be at least 8 characters long and contain numbers, letters, and special characters.
After setting your password, you need to answer some security questions. You can choose to accept or decline each option.
You will then be prompted to delete the anonymous user. It is recommended that you delete anonymous users as this will improve the security of the system. Select [Y] and press [Enter] to continue.
Finally, you will be prompted to disable remote root login. It is recommended that you disable this setting to improve system security. Select [Y] and press [Enter] to continue.
Step 4: Log in to the MySQL database
Now you can log in to the MySQL database using the following command:
mysql -u root -p
This command will prompt you for the MySQL root user password, enter You can log in to the MySQL database with the MySQL root user password you have set.
Step 5: Complete the MySQL installation
Now you have completed all the steps to install the MySQL database on CentOS 7. During your web development process, you can use MySQL to manage databases and connect to MySQL databases using PHP, Python, or other programming languages.
If you need more help, check out the official MySQL documentation or search the community for solutions.
The above is the detailed content of centos7 mysql installation. For more information, please follow other related articles on the PHP Chinese website!