centos7 mysql5.7.17源码安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 mysql5.7.17源码安装相关的知识,希望对你有一定的参考价值。
centos7 mysql5.7.17源码安装
**安装前准备
操作系统环境:Centos 7.2
1、解决依赖包并下载源码包至/home/soft/目录下
[[email protected] ~]# yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison [[email protected] ~]# cd /home/soft/ [[email protected] soft]# wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz [[email protected] soft]#tar -zxvf boost_1_59_0.tar.gz #解压 [[email protected] soft]#mv boost_1_59_0 /usr/local/boost #移动至/usr/local/boost/目录下 [[email protected] soft]# wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.17.tar.gz [[email protected] soft]# tar -zxvf mysql-5.7.17.tar.gz
2、新建MySQL用户和用户组,创建/mydata/data目录存放mysql数据
[[email protected] soft]# groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql [[email protected] soft]# mkdir -pv /mydata/data
3、预编译及编译安装
[[email protected] soft]# cd mysql-5.7.17 [[email protected] mysql-5.7.17]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DDEFAULT_CHARSET=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=/usr/local/boost -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DWITH_EMBEDDED_SERVER=1 \
注:
DCMAKE_INSTALL_PREFIX=/usr/local/mysql:安装路径
DMYSQL_DATADIR=/mysql/data:数据文件存放位置
DSYSCONFDIR=/etc:my.cnf路径
DWITH_MYISAM_STORAGE_ENGINE=1:支持MyIASM引擎
DWITH_INNOBASE_STORAGE_ENGINE=1:支持InnoDB引擎
DMYSQL_UNIX_ADDR=/tmp/mysqld.sock:连接数据库socket路径
DMYSQL_TCP_PORT=3306:端口
DENABLED_LOCAL_INFILE=1:允许从本地导入数据
DWITH_PARTITION_STORAGE_ENGINE=1:安装支持数据库分区
DEXTRA_CHARSETS=all:安装所有的字符集
DDEFAULT_CHARSET=utf8:默认字符
DWITH_EMBEDDED_SERVER=1:嵌入式服务器
[[email protected] mysql-5.7.17]# make install #编译安装
4、设置启动脚本,开机自启动
[[email protected] ~]# cp /home/soft/mysql-5.7.17/support-files/mysql.server /etc/init.d/mysqld [[email protected] ~]# chmod +x /etc/init.d/mysqld [[email protected] ~]# systemctl enable mysqld mysqld.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig mysqld on [[email protected] ~]# chown -R mysql:mysql /usr/local/mysql
5、拷贝my.cnf至/etc/目录下,并初始化数据库
[[email protected] ~]# cp /home/soft/mysql-5.7.17/support-files/my-default.cnf /etc/my.cnf [[email protected] ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data
注:初始化最后一行是root用户密码([email protected]: ,5j1Qj_LLAek)
6、配置mysql环境变量,并启动服务
[[email protected] data]# vim /etc/profile
#编辑/etc/profile文件在最后添加如下两行
PATH=/usr/local/mysql/bin:$PATH export PATH
[[email protected] data]# source /etc/profile #刷新生效 [[email protected] mysql]# systemctl start mysqld.service [[email protected] mysql]# ss -tlpn |grep ‘3306‘ LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=25268,fd=20))
7、root管理员修改密码
[[email protected] mysql]#mysql -uroot -p,5j1Qj_LLAek mysql> SET PASSWORD = PASSWORD(‘111111‘); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
本文出自 “一万小时定律” 博客,请务必保留此出处http://daisywei.blog.51cto.com/7837970/1896614
以上是关于centos7 mysql5.7.17源码安装的主要内容,如果未能解决你的问题,请参考以下文章