1、 Uninstall the old version of mysql (skip if none)
1. Use the following command to check whether mysql is installed
rpm -qa|grep -i mysql

2. Uninstall if any

yum remove MySQL-server-5.6.35-1.el6.i686

yum remove MySQL-devel-5.6.35-1.el6.i686

3. Delete related directory

whereis mysql

rm -rf /usr/share/mysql

rm -rf /var/lib/mysql

mv /usr/lib/mysql /usr/lib/mysql.bak #It was not sure that it was created by the rmp package at that time, and its name was temporarily changed

2、 Install MySQL

4. Install the package required for compiling code

yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl perl-devel

5. Download MySQL 5.7.17

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12.tar.gz

tar zxvf mysql-5.7.12.tar.gz

cd mysql-5.7.12

6. Create a directory recursively: mkdir - p/usr/local/mysql/data

7. Download boost
MySQL 5.7.17 needs this package to compile. The wget network will fail to download. You can download it through the browser and upload it
wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

Unzip:
tar zxvf boost_1_59_0.tar.gz

8. Compile MySQL:

 cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/etc \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \-DWITH_PARTITION_STORAGE_ENGIN E=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DWITH_BOOST=/home/boost_1_59_0

 Centos6 source code compilation and installation MySQL 5.7.17 tutorial

Compile and execute: make

Check compilation: echo $? Tips zero That is, compilation is OK

Installation: make install

Clear screen: make clean

To check whether there are user groups: cat /etc/group

To create a mysql user group: groupadd mysql

Add the user mysql days to the MySQL user group (the first mysql is the user group): useradd -g mysql mysql

Modify MySQL permissions: chown -R mysql:mysql /usr/local/mysql

Enter the MySQL installation directory: cd /usr/local/mysql/bin

Execute the initialization configuration script to create the database and tables that come with the system:

./mysqld --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

A default password will be generated here. Be sure to write it down: root@localhost : yfagfl! T&6iq

Copy file: cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

Set to start automatically after startup: chkconfig mysql on

Modify the default configuration my.cnf:
vi /etc/my.cnf
Write the following content, which is the most basic. If you want to optimize, you can optimize yourself

 [mysqld] port=3306 basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock lower_case_table_names=1 max_connect_errors=6000 max_connections=1024 query_cache_limit = 2M

Start MySQL: service mysql start
(The specific startup program of mysql is in/etc/rc.d/init.d/mysql. Note that sometimes it is not mysql, it may be mysqld or mysql.)

View the MySQL exception log:/usr/local/mysql/data under the installation path

9. Configure Users

Set PATH
vi /etc/profile
Add the following line where appropriate
PATH=$PATH:/usr/local/mysql/bin
take effect:
source /etc/profile
see:
echo $PATH

10. Modify root default password
Log in to MySQL:
mysql -uroot -p
Enter the default password generated during installation

Change Password:
mysql> SET PASSWORD = PASSWORD('mysql5635');

Refresh permissions:
mysql> flush privileges;

Set mydba user to access remotely

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql5635' WITH GRANT OPTION;

Firewall settings can refer to http://www.cnblogs.com/ShanFish/p/6519950.html

Firewall off: /etc/sysconfig/iptables stop

Firewall configuration: vi /etc/sysconfig/iptables

join

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

12. Supplement

Log in to the terminal again after exiting

[ root@localhost ~]# mysql -uroot -p

bash: mysql: command not found

Use the full path to log in

[ root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p
(The complete path of MySQL login is in/usr/local/mysql/bin/mysql - uroot - p)

Enter password:

Finally, establish a soft link, and use this method when other common commands such as mysqladmin and mysqldump are unavailable

[ root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin

Run the export command directly to define variables [valid only for the current shell (temporary)]

[ root@VMUest ~]# export PATH=/usr/local/mysql/bin:$PATH

[ root@VMUest ~]# echo $PATH

It is only valid for the current shell, so you can use mysql when you first configure it, but not when you log out. Later, write export to the file/etc/profile, and you can permanently

Naicat remote local error resolution 10061 analysis;

1. The firewall may not be open

2. Find my. cnf in ETC and add bind address=0.0.0.0 (Windows is my. ini)

3. Set permissions in MySQL: GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql5635' WITH GRANT OPTION;

Reference article:
https://www.cnblogs.com/AllenJol/p/6609929.html
https://blog.csdn.net/embracejava/article/details/53996794
https://blog.csdn.net/weixin_37750188/article/details/78816712