当前位置:Gxlcms > 数据库问题 > mysql5.7.17源码安装

mysql5.7.17源码安装

时间:2021-07-01 10:21:17 帮助过:13人阅读

创建用户和目录
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /data/mysql/standby/data
mkdir -p /data/mysql/standby/tmp
mkdir -p /data/mysql/standby/elog
mkdir -p /data/mysql/standby/blog

chown -R mysql:root /data/mysql

配置yum源

cd /etc/yum.repos.d/
rm -rf *

vi centos-base.repo
[kingsql]
name=kingsql
baseurl=file:///media/oraclelinux6.9/Packages
enabled=1
gpgcheck=0
gpgkey=file:///media/oraclelinux6.9/RPM-GPG-KEY-oracle

rpm -ivh vsftpd-2.2.2-12.el6_5.1.x86_64.rpm
rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm

rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
rpm -ivh libxml2-2.7.6-14.el6_5.2.x86_64.rpm

rpm -ivh libxml2-python-2.7.6-14.el6_5.2.x86_64.rpm
rpm -ivh createrepo-0.9.9-22.el6.noarch.rpm

createrepo ./
yum clean all
yum makecache

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

解压安装包
cd /data/mysql
tar -xvf mysql-boost-5.7.17.tar.gz

编译
cd /data/mysql/mysql-5.7.17

编译(5.5版本后编译参数为大写)
[root@localhost mysql-5.6.41]# cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DENABLED_LOCAL_INFILE=1
参数意义:
1.安装目录参数
-DCMAKE_INSTALL_PREFIX                  根目录安装路径      
-DINSTALL_SBINDIR                       mysqld目录       
-DMYSQL_DATADIR                         数据存储目录  
-DSYSCONFDIR                            配置文件(my.cnf)目录       
-DINSTALL_PLUGINDIR                     插件目录       
-DINSTALL_MANDIR                        手册文件目录  
-DINSTALL_SHAREDIR                      共享数据目录  
-DINSTALL_LIBDIR                        Library库目录 
-DINSTALL_INCLUDEDIR                    Header安装目录
-DINSTALL_INFODIR                       信息文档目录 
2.存储引擎参数(默认安装innodb存储引擎)
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 
Or
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
3.相关库的参数
-DWITH_READLINE=1                        readline库
-DWITH_SSL=system                        SSL库
-DWITH_ZLIB=system                       zlib库
-DWITH_LIBWRAP=0                         libwrap库   
4.其他参数
-DMYSQL_TCP_PORT=3306                    TCP/IP端口        
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock       UNIX socket文件
-DENABLED_LOCAL_INFILE=1                 启用加载本地数据
-DEXTRA_CHARSETS=all(默认:all)        扩展字符支持
-DDEFAULT_CHARSET=utf8                   默认字符集
-DDEFAULT_COLLATION=utf8_general_ci      默认字符校对
-DWITH_EMBEDDED_SERVER=1                 嵌入式服务器
-DMYSQL_USER=mysql                       mysqld运行用户
-DWITH_DEBUG=0(默认禁用)               调试模式
-DENABLE_PROFILING=0(默认启用)         Profiling
-DWITH_COMMENT=‘string‘                  注释存储类型

执行编译
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_BOOST=/data/mysql/mysql-5.7.17/boost

mysql 5.5以上源码安装都需要boost
注意下载的源码包是带boost的,编译的时候要指定一下boost目录,就在源码包里面 -DWITH_BOOST=/data/mysql/mysql-5.7.17/boost

安装
make && make install

vi /data/mysql/standby.cnf
[mysqld]
#************** basic ***************
user                            =mysql
datadir                         =/data/mysql/standby/data
basedir                         =/usr/local/mysql
tmpdir                          =/data/mysql/standby/tmp
secure_file_priv                =/data/mysql/standby/tmp
port                            =20001
socket                          =/data/mysql/standby/mysql.sock
pid_file                        =/data/mysql/standby/mysql.pid

log_error                       =/data/mysql/standby/elog/mysql.err
#log_output                      ="TABLE,FILE"
slow_query_log                  =ON
slow_query_log_file             =/data/mysql/standby/elog/slow.log
long_query_time                 =1
log_queries_not_using_indexes   =0
log_throttle_queries_not_using_indexes = 10
general_log                     =OFF
general_log_file                =/data/mysql/standby/elog/general.log

expire_logs_days                =7
sync_binlog                     =1
server_id                       =101
log-bin                         =/data/mysql/standby/blog/mysql-bin
log-bin-index                   =/data/mysql/standby/blog/mysql-bin.index

初始化
/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql/standby/data --basedir=/usr/local/mysql   这里如果用--initialize-insecure参数,就不用初始密码


########/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/standby.cnf --initialize-insecure --user=‘mysql‘ --log_error_verbosity --explicit_defaults_for_timestamp &  这个初始化语句有待修改


临时密码_oeYWeIgk0zt

echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile

/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/standby.cnf --ledir=/usr/local/mysql/bin &

mysql -S /data/mysql/standby/mysql.sock -u root -p
输入临时密码

mysql> alter user ‘root‘@‘localhost‘ identified by ‘oracle‘;
Query OK, 0 rows affected (0.06 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


允许远程机器连接 update user set host=‘%‘ where user=‘root‘;
flush privileges;

mysql5.7.17源码安装

标签:文件   5.5   ide   mes   tar -xvf   char   comm   初始化   14.   

人气教程排行