mysql is installed by decompressing the installation mode, so that we can install the version we want. The advantage of this installation mode is that I can install it wherever I want. It's easy and pleasant. The installation method of this device is similar to that of jdk, that is, decompressing, and then configuring permissions, services, and environment variables.
Download address
#Domestic download address
http://ftp.ntu.edu.tw/MySQL/Downloads/
#I downloaded version 5.6
http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
#My own download address
http://yellowcong.qiniudn.com/mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
Unzip installation
#download
wget http://yellowcong.qiniudn.com/mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
#compression
tar -zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
#Move to mysql directory
mv mysql-5.6.38-linux-glibc2.12-x86_64 /usr/local/mysql
#Install libaio, which is dependent on mysql. You need to install it
yum install -y libaio
#Add user group
groupadd mysql
#No mysql user login required
useradd -r -g mysql -s /bin/false mysql
#Set the permission of mysql and modify it to your mysql installation directory
chown -R mysql:mysql /usr/local/mysql
#Execute installation script
./scripts/mysql_install_db --user=mysql
#service mysql start
./support-files/mysql.server start
#Method 1: change the password. After the change, a string of yellow words will be prompted to indicate that the password change is finished.
#Warning: Using a password on the command line interface can be insecure.
./bin/mysqladmin -u root password 'root'
#Method 2 (not recommended), set the password directly through this
./bin/mysql_secure_installation
#Log in to the database
./bin/mysql -u root -proot
Download and extract mysql compressed file
Move and pressure to mysql directory
Add mysql user
Add permissions to the mysql directory installed
Install mysql as a user of mysql
Change the password. If the yellow one below appears, it means that the password has been changed
Login database with password
Add to service
#Copy to init.d directory
cp support-files/mysql.server /etc/init.d/mysqld
#Add startup
#chkconfig --add mysqld
#I added it directly using the following command
systemctl enable mysqld
#Check whether it is started or not
#chkconfig mysqld on
systemctl is-enabled mysqld
#Restart service
service mysqld restart
#View service status
service mysqld status
Copy to init.d directory and add to boot
Restart service, view status
Check whether the boot is added successfully
Add environment variable
/usr/local/mysql/bin
#Add environment variable of mysql
vim /etc/profile
#Add the following configuration
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
#Configuration takes effect
source /etc/profile
Add environment variable
We are in the root directory to test whether the environment variables are effective, but we can use mysql command directly, which means that we have done it.
Error set
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
This error is reported because mysql is not started.
#After starting the service, change the password
./support-files/mysql.server start
#
Reference article
https://www.cnblogs.com/coderls/p/6848873.html
https://www.cnblogs.com/wangdaijun/p/6132632.html