Compile and install MySQL 5.7.29 from source code in CentOS

How to compile and install MySQL 5.7.29 from source code in CentOS
Install compilation tools and requirement packages:
yum install gcc gcc-c++ ncurses-devel cmake bison
Download mysql source code
wget https://github.com/mysql/mysql-server/archive/mysql-5.7.29.tar.gz
Compile and install MySQL

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
cd /tmp
tar xvf mysql-5.7.29.tar.gz
cd mysql-5.7.29/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql

make
make install

Configuring MySQL

mysql_secure_installation

Setting mysql

chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16
mkdir -p /var/mysql/
mkdir -p /var/mysql/data/
mkdir -p /var/mysql/log/
chown -R mysql:mysql /var/mysql/
cd support-files/
cp my-large.cnf /var/mysql/my.cnf
cp mysql.server /etc/rc.d/init.d/mysqld

/usr/local/mysql/scripts/mysql_install_db \
–defaults-file=/var/mysql/my.cnf \
–basedir=/usr/local/mysql \
–datadir=/var/mysql/data \
–user=mysql

chmod +x /etc/init.d/mysqld

vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/var/mysql/data

Run mysql on system boot:

chkconfig –add mysqld
chkconfig –level 345 mysqld on

Start the service:

service mysqld start