CentOS 7 安装MySQL 5.7.15/MySQLl 5.7.17

前端之家收集整理的这篇文章主要介绍了CentOS 7 安装MySQL 5.7.15/MySQLl 5.7.17前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


http://www.cnblogs.com/zhnhelloworld/p/5861479.html


CentOS 7 安装MysqL 5.7.15

1. 安装环境:CentOS 7 64位 MysqL 5.7.15

2. 去MysqL官方网站下载MysqL源码安装包,注意,一定要选择下图的源代码版,否则cmake时会报错:



3. 预先安装依赖软件:

yum install -y gcc-c++ make cmake bison bison-devel ncurses-devel libaio-devel perl perl-Data-Dumper



4. 创建MysqL用户用户
先查看是否已经创建:

cat /etc/passwd | grep MysqL
cat /etc/group | grep MysqL

没有创建则新建MysqL用户以及用户组:

1 groupadd MysqL
2 useradd -r -g MysqL MysqL



5. 我把源码包放在了/tmp目录下,解压缩MysqL

tar -zxv -f MysqL-5.7.15.tar.gz



6. 创建MysqL安装目录和数据目录

1 mkdir /usr/local/MysqL
2 mkdir /usr/local/MysqL/data



7. 创建boost文件夹并复制boost文件到这个目录中,否则cmake会报错,本示例中使用的是boost_1_59_0.tar.gz

mkdir /usr/local/boost
cp /tmp/boost_1_59_0.tar.gz /usr/local/boost/



8. cmake安装MysqL
复制代码
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL
-DMysqL_UNIX_ADDR=/usr/local/MysqL/MysqL.sock
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DMysqL_DATADIR=/usr/local/MysqL/data
-DMysqL_USER=MysqL
-DMysqL_TCP_PORT=3306
-DWITH_BOOST=/usr/local/boost/boost_1_59_0.tar.gz


复制代码

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DMysqL_UNIX_ADDR=/usr/local/MysqL/MysqL.sock -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMysqL_DATADIR=/usr/local/MysqL/data -DMysqL_USER=MysqL -DMysqL_TCP_PORT=3306 -DWITH_BOOST=/usr/local/boost/boost_1_59_0.tar.gz

9. 安装过程会持续一段时间,耐心等待。make && make install10. 安装完成之后修改/etc/my.cnfvim /etc/my.cnf复制代码[MysqLd]basedir=/usr/local/MysqLdatadir=/usr/local/MysqL/datasocket=/usr/local/MysqL/MysqL.socksymbolic-links=0skip-grant-tables[MysqLd_safe]log-error=/usr/local/MysqL/logs/MysqL.logpid-file=/usr/local/MysqL/localhost.localdomain.pid!includedir /etc/my.cnf.d    复制代码mkdir /usr/local/MysqL/logs11. 修改MysqL目录所有者chown -R MysqL:MysqL /usr/local/MysqL12. 添加MysqL服务cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqL13. 启动MysqLservice MysqL start显示启动成功:Starting MysqL....... SUCCESS!14. 开启MysqL/usr/local/MysqL/bin/MysqL -uroot -p15. 完成!

原文链接:https://www.f2er.com/centos/378888.html

猜你在找的CentOS相关文章