CentOS 源码安装MYSQL-5.6
一、 环境准备
linux centos7.3系统一台主机即可;
mysql官网:
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