First of all: to have root user authority.
View Linux operating system information command:
uname -a
delete the existing MySQL.
rpm -qa | grep -i mysql #Uninstall
MySQL
rpm -e Print command mysql.rpm as above command #Delete
MySQL service
chkconfig --list|grep -i mysql
chkconfig --del mysql #Delete
scattered MySQL folder
whereis mysql or find / -name mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
rm -rf /usr/my.cnf
Download:
mysql-5.7.16-linux-glibc2.5-i686.tar
Install MySQL5.7.16 The
following takes centos7-64 bit to install mysql-5.7.16-linux-glibc2.5-x86_64.tar as an example:
1. groupadd mysql;
2. useradd -r -g mysql mysql ## Add a user
3.
Unzip tar.gz
tar xzvf mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
Unzip tar
tar --xvf mysql-5.7.16-linux-glibc2.5-x86_64.tar
4. Then mv uncompressed package mysql ## is equivalent to renaming
mv mysql-5.7.16-linux-glibc2.5-x86_64 mysql
5. chown -R mysql:mysql ./ ##Enter the mysql package and authorize this package to mysql
6. Register the mysql command to Linux
6.1: vim /etc/profile
6.2: Add at the end of the etc/profile file: export PATH=$PATH:/usr/local/src/mysql/bin
6.3: source /etc/profile
6.4. Install masql
mysqld --initialize --user=mysql --basedir=/usr/local/src/mysql --datadir=/usr/local/src/mysql/data
##Enter the path where the mysql file name basedir is mysql ,
Datadir is the mysql data package, which stores mysql's own package.
Important: Here you need to record the generated temporary password, as above: CdmKy#mu9ZDs
7, mysql_ssl_rsa_setup --datadir=/usr/local/src/mysql/data
##Safe link
8、cd support-files/
##进入mysql support-files
9、cp my-default.cnf /etc/my.cnf
10、cp mysql.server /etc/init.d/mysql
11. vim /etc/init.d/mysql
##Modify basedir= own path modify datadir= own path
For example:
basedir=/usr/local/src/mysql
datadir=/usr/local/src/mysql/data
Esc & :wq save
12, service mysql start ## Start mysql
mysql operation:
13. mysql -uroot -p or mysql -u root -p
enter the temporary password.
If the temporary password is not found, execute cat /root/.mysql_secret, as shown below:
Password set for user'root@localhost' at 2016 -12-08 17:38:03
P4i-lNA3ZT6s
##Modify password
14, mysql>set password=password('root');
##Open remote connection
15, mysql>grant all privileges on *.* to root@'%' identified by'root';
## Refresh privileges
16, mysql>flush privileges;
17、mysql>exit;