一、 环境准备
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
原文地址:https://www.cnblogs.com/-bobo/p/11643172.html