There are two main ways to install MySQL under Linux, one is binary installation, and the other is to use RPM package installation. This article will introduce the steps to install MySQL through RPM package.
1. Download the RPM package of MySQL
To download the RPM package of MySQL, you can visit the MySQL official website download page (https://dev.mysql.com/downloads/mysql/). There are multiple versions and platforms of MySQL available for download on the download page. We need to first select the appropriate version of the RPM package to download.
2. Install the MySQL RPM package
Under Linux, the installation of the RPM package is very simple. Just use the following command:
rpm -ivh package.rpm
Among them, package.rpm represents the name of the RPM package file you want to install.
After the installation is completed, we can use the following command to check whether MySQL is installed correctly:
rpm -qa | grep mysql
If the installation is successful, the following information will be displayed :
mysql-*.rpm
3. Setting up MySQL
After the installation of MySQL is completed, some settings are required for normal use. Here, we will set the MySQL root password and create a system user "mysql" for MySQL.
First, run the following command to start MySQL:
/etc/init.d/mysqld start
Enter MySQL:
mysql -u root
Set the MySQL root password:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');
Among them, password represents the password you want to set root password.
Create MySQL system user "mysql":
useradd mysql
Add user "mysql" to user group "mysql":
groupadd mysql
usermod -a -G mysql mysql
Set the permissions of the MySQL data directory to "mysql" and both the user and the user group can read and write:
chown -R mysql:mysql /var/lib/mysql
After the above steps are completed, we can check whether MySQL is working properly through the following command:
mysqladmin -u root -p version
Enter before Set the MySQL root password. If information about the MySQL version is output, it means that MySQL has been successfully installed and running.
4. Uninstall MySQL
In some cases, we may need to uninstall MySQL. Uninstalling MySQL is also easy, just execute the following command:
rpm -e mysql*
The above is the entire process of installing MySQL using the RPM package. If you want to learn MySQL more deeply, you can check out the official documentation of MySQL (https://dev.mysql.com/doc/).
The above is the detailed content of linux mysql installation rpm installation. For more information, please follow other related articles on the PHP Chinese website!