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