There are usually many ways to install MySQL database in Linux systems, including source code compilation, binary installation and use of package managers. However, this article will introduce the installation method of MySQL database through Tar package in Linux system. Below, this article will introduce the installation process of MySQL database through Tar package step by step, and provide some practical commands for readers' reference.
tar -xzvf mysql-x.x.xx-linux-glibc2.12-x.xx.tar.gz
where x.x.xx represents The version number of MySQL may change. After executing the above command, a mysql-x.x.xx-linux-glibc2.12-x.xx folder will be generated, which contains all files and directories of MySQL.
useradd mysql
Copy the files in the MySQL folder to the system directory:
cp -R ./mysql-x.x.xx-linux-glibc2.12-x.xx /usr/ local/mysql
Copy the MySQL configuration file my.cnf to the /etc directory:
cp /usr/local/mysql/support-files/my-default.cnf /etc/my .cnf
Use the following command to update the data directory permissions in MySQL:
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
./bin/mysqld --initialize -- user=mysql
This command will generate the MySQL root password, which is stored in the error.log file.
systemctl start mysqld
Use the following command to modify:
mysqladmin -u root password 'newpassword'
Among them, 'newpassword' represents the new password.
vi /etc/my.cnf
Add the following parameters in the file:
bind-address=your-server-ip
your-server-ip within the quotation marks refers to The public IP address of this machine, not the local unique address 127.0.0.1.
Start the MySQL service:
systemctl start mysqld
Stop the MySQL service:
systemctl stop mysqld
Restart the MySQL service :
systemctl restart mysqld
View MySQL service status:
systemctl status mysqld
Enter MySQL:
mysql -u root - p
Exit MySQL:
exit
The above is the process and common commands for installing the MySQL database through the Tar package introduced in this article. Although this method is relatively complicated, it allows you to have a deeper understanding of the MySQL database and learn to use some practical commands.
The above is the detailed content of How to install linux mysql tar. For more information, please follow other related articles on the PHP Chinese website!