# useradd -M -s /sbin/nologin MysqL
--2.安装需要的库,编译器
# yum install ncurses-devel openssl-devel cmake -y
--3.解压
# tar zxvf MysqL-5.6.35.tar.gz
# cd MysqL-5.6.35
--4.编译安装
# 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_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMysqL_USER=MysqL \
-DWITH_DEBUG=0 \
-DWITH_SSL=system
# make
# make install
--5.拷贝模版,作为配置文件
# cp support-files/my-default.cnf /etc/my.cnf
--6.设置MysqL权限
# chown -R MysqL.MysqL /usr/local/MysqL/
# /usr/local/MysqL/scripts/MysqL_install_db --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data --user=MysqL
# chown -R root /usr/local/MysqL/
# chown -R MysqL /usr/local/MysqL/data/
--8.设置MysqL开机自启动
# cp support-files/MysqL.server /etc/init.d/MysqLd
# chmod +x /etc/init.d/MysqLd
# chkconfig MysqLd on
--9.测试并运行MysqL
#service MysqLd start
--10.修改MysqL管理员密码
#/usr/local/MysqL/bin/MysqLadmin -u root password '要设置的密码'
--11.使用用户登录MysqL
# /usr/local/MysqL/bin/MysqL -u root -p
--12.加入环境变量
#echo 'PATH=/usr/local/MysqL/bin/:$PATH' >>/etc/profile
# source /etc/profile
原文链接:https://www.f2er.com/centos/378697.html