RED HAT installation MySQL5.7.19

1.Download binary package, mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz link is the official website Wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

2. Unzip, rename Tar zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ Mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql

3. Delete the library file mysql-libs (included with the linux system) Rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64

4. Add user mysql Useradd -M -s /sbin/nologin mysql

5.Add data directory under /usr/local/mysql Mkdir data

6. Change the directory and file owner under the mysql directory, the group belongs to mysql

 chown -R mysql:mysql  /usr/local/mysql/

7. Install and initialize the database Cd /usr/local/mysql/bin carried out: ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages =en_US

8. Create my.cnf in the /etc/ directory and write the following #[mysql] Basedir=/usr/local/mysql/ Datadir=/usr/local/mysql/data/

9. Start mysql service Cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql Service mysql start

10. Set mysql boot

chkconfig --add mysql   chkconfig --list mysql   chkconfig --level 35 mysql on  

11. Login mysql Cd /usr/local/mysql/bin/ ./mysql -u root -p The password is the password generated in step 7

12 to set the password, the original password is installed and initialized in the database (generated in step 7)

mysql>  set password=password("root");

13 Set the remote login permission

mysql>  grant all privileges on *.* to'root' @'%' identified by 'root'; mysql> flush privileges; mysql> quit

14. Add mysql to the environment variable You can log in to the mysql database in any directory.

方法1:

Directly run the command export PATH=$PATH:/usr/local/mysql/bin. After logging out or logging out of the system, PATH is set. Will fail.

方法2:

1. Execute vi ~/.bash_profile to modify the PATH line in the file, and add /usr/local/mysql/bin to the PATH=$PATH:$HOME/bin line. Only valid for the currently logged in user.

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

2. Execute the command source ~/.bash_profile to make it effective

方法3:

1, vi /etc/profile file, add the following command at the end of the file, right All login users take effect

  export PATH=$PATH:/usr/local/mysql/bin

2, execute the command source /etc/profile to make it effective