一、 环境准备
Linux CentOS7.3系统一台主机即可;
MysqL官网:https://www.mysql.com/
MysqL软件下载:http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.6/
二、 MysqL的编译和安装
1:准备工作
[[email protected] ~]# rpm -q MysqL-server MysqL //查看MysqL是否已经安装
[[email protected] ~]# cd /media/cdrom/Packages/ //进入光盘所在目录
[[email protected] Packages]# rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm //安装软件
ncurses是字符终端下屏幕控制的基本库,包括面板和菜单功能,在TTY下登录到主机上MysqL需要的。
[[email protected] Packages]# cd
[[email protected] ~]# tar zxvf cmake-2.8.6.tar.gz //解包
[[email protected] ~]# cd cmake-2.8.6
[[email protected] cmake-2.8.6]# ./configure //配置
[[email protected] cmake-2.8.6]# gmake && gmake install //编译安装
2:安装MysqL
[[email protected] cmake-2.8.6]# cd
[[email protected] ~]# groupadd MysqL
[[email protected] ~]# useradd -M -s /sbin/nologin MysqL -g MysqL
[[email protected] ~]# cd /usr/src
[[email protected] src]# tar zxvf MysqL-5.6.36.tar.gz
[[email protected] src]# cd MysqL-5.6.36
[[email protected] MysqL-5.6.36]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
-DDEFAULT_COLLATION:用于指定数据集如何排序,以及字符串的比对规则
[[email protected] MysqL-5.6.36]# make
[[email protected] MysqL-5.6.36]# make install
3:安装后的调整
[[email protected] MysqL-5.6.36]# cd
[[email protected] ~]# chown -R MysqL:MysqL /usr/local/MysqL/
[[email protected] ~]# rm -rf /etc/my.cnf
[[email protected] ~]# cd MysqL-5.6.36
[[email protected] MysqL-5.6.36]# cp support-files/my-default.cnf /etc/my.cnf
4:初始化数据库
[[email protected] MysqL-5.6.36]# yum -y install autoconf
[[email protected] MysqL-5.6.36]# /usr/local/MysqL/scripts/MysqL_install_db --user=MysqL --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data/
[[email protected] MysqL-5.6.36]# echo "PATH=$PATH:/usr/local/MysqL/bin" >> /etc/profile
[[email protected] MysqL-5.6.36]# . /etc/profile \\点后有个空格
5:添加系统服务
方法1:
[[email protected] MysqL-5.6.36]# cp support-files/MysqL.server /etc/rc.d/init.d/MysqLd
[[email protected] MysqL-5.6.36]# chmod +x /etc/rc.d/init.d/MysqLd
[[email protected] MysqL-5.6.36]# chkconfig --add MysqLd
[[email protected] MysqL-5.6.36]# service MysqLd start
[[email protected] MysqL-5.6.36]# /etc/init.d/MysqLd status
[[email protected] MysqL-5.6.36]# netstat -anpt | grep MysqLd
[[email protected] MysqL-5.6.36]# MysqLadmin -u root password ‘pwd123‘
6:访问MysqL
[[email protected] ~]# MysqL -u root -p
输入相应的密码;
MysqL> show master logs;
MysqL> exit