这篇文章主要介绍了CentOS7怎么编译安装MySQL 8.0的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇CentOS7怎么编译安装MySQL 8.0文章都会有所收获,下面我们一起来看看吧。
CentOS编译安装MySQL的教程网上有很多,基本上大同小异。但是安装软件有时就可能因为一个细节安装失败。
0.前期准备条件
•查看linux的版本
[root@mysql etc]# cat /etc/RedHat-releaseCentOS Linux release 7.3.1611 (Core)•Could NOT find Cursesyum install ncurses-devel•Bison executable not found in PATHyum install bison
备注: 安装过程中会缺少基础包,本实例环境缺少上述包,先提前安装相应的包
cmake的源编译安装
[root@db software]# nohup tar zxvf cmake-3.11.1.tar.gz &[root@db software]# cd cmake-3.11.1[root@db cmake-3.11.1]# ./configure[root@localhost cmake-3.0.1]# gmake && make install
wolfssl包的部署安装[可选项]
*. 从wolfssl.com网站下载wolfssl-3.13.0.zip压缩包*. 解压至/data/software/mysql-8.0.11/extra/wolfssl-3.13.0目录中。*. cd extra/wolfssl-3.13.0/IDE/MYSQL*. 执行do.sh脚本*. use -DWITH_SSL=wolfssl for CMake
openssl和openssl-devel[本实验使用的是system ssl]
yum install –y openssl openssl-devel
mysql的编译安装
[root@mysql software]#tar zxvf mysql-8.0.11.tar.gz[root@mysql software]# cd mysql-8.0.11/[root@mysql software]# mkdir Zdebug[root@mysql software]# cd Zdebugcmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNODB_MEMCACHED=ON \-DWITH_SSL=system \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \-DCOMPILATION_COMMENT="zsd edition" \-DDOWNLOAD_BOOST=1 \-DWITH_BOOST=/tmp \-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock \-DSYSCONFDIR=/data/mysqldata/3306 > /data/software/mysql-8.0.11/Zdebug/mysql_cmake80.log 2>&1
出现下列日志:
............-- Configuring done-- Generating done-- Build files have been written to: /data/software/mysql-8.0.11/Zdebug............
说明编译成功,其中-DWITH_SSL=system用的是linux操作系统的openssl,需要安装openssl和openssl-devel包,才可以被编译
如果需要编译安装快速,可以运用多线程加快编译安装,命令如下:
make -j 12make install
•MySQL 8.0的软件目录结构
[root@mysql Zdebug]# cd /usr/local/mysql/[root@mysql mysql]# ls -ltotal 612drwxr-xr-x. 2 root root 4096 May 16 14:20 bindrwxr-xr-x. 2 root root 55 May 16 14:20 docsdrwxr-xr-x. 3 root root 266 May 16 14:20 includedrwxr-xr-x. 4 root root 173 May 16 14:20 lib-rw-r--r--. 1 root root 301518 Apr 8 14:44 LICENSE-rw-r--r--. 1 root root 301518 Apr 8 14:44 LICENSE-testdrwxr-xr-x. 4 root root 30 May 16 14:20 mandrwxr-xr-x. 10 root root 4096 May 16 14:21 mysql-test-rw-r--r--. 1 root root 687 Apr 8 14:44 README-rw-r--r--. 1 root root 687 Apr 8 14:44 README-testdrwxr-xr-x. 28 root root 4096 May 16 14:21 sharedrwxr-xr-x. 2 root root 90 May 16 14:21 support-files
创建mysql用户&并修改相关文件
[root@mysql mysql]# groupadd mysql[root@mysql mysql]# useradd -g mysql mysql
设置用户操作系统资源的限制
[root@localhost cmake-3.0.1]# vi /etc/security/limits.confmysql soft nproc 65536mysql hard nproc 65536mysql soft nofile 65536mysql hard nofile 65536
验证limit是否生效
[root@mysql ~]# su - mysql[mysql@mysql ~]$ ulimit -a
日志如下:
open files (-n) 65536max user processes (-u) 65536............
创建MySQL数据目录及赋予相应权限
#cd /data/#mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,innodb_ts,innodb_log},backup,scripts}#chown -R mysql:mysql mysqldata#su - mysql
配置my.cnf文件
$vi /data/mysqldata/3306/my.cnf[client]port = 3306socket = /data/mysqldata/3306/mysql.sock# The MySQL server[mysqld]port = 3306user = mysqlsocket = /data/mysqldata/3306/mysql.sockpid-file = /data/mysqldata/3306/mysql.pidbasedir = /usr/local/mysqldatadir = /data/mysqldata/3306/datatmpdir = /data/mysqldata/3306/tmpopen_files_limit = 60000explicit_defaults_for_timestampserver-id = 1203306lower_case_table_names = 1character-set-server = utf8federated#sql_mode=STRICT_TRANS_TABLESmax_connections = 1000max_connect_errors = 100000interactive_timeout = 86400wait_timeout = 86400sync_binlog=0back_log=100default-storage-engine = InnoDBlog_slave_updates = 1#*********** Logs related settings ***********log-bin = /data/mysqldata/3306/binlog/mysql-binbinlog_format= mixedbinlog_cache_size=32mmax_binlog_cache_size=64mmax_binlog_size=512mlong_query_time = 1log_output = FILElog-error = /data/mysqldata/3306/mysql-error.logslow_query_log = 1slow_query_log_file = /data/mysqldata/3306/slow_statement.log#log_queries_not_using_indexesgeneral_log = 0general_log_file = /data/mysqldata/3306/general_statement.log#expire-logs-days = 14binlog_expire_logs_seconds = 1728000relay-log = /data/mysqldata/3306/binlog/relay-binrelay-log-index = /data/mysqldata/3306/binlog/relay-bin.index#****** MySQL Replication New Feature*********master-info-repository=TABLErelay-log-info-repository=TABLErelay-log-recovery#*********** INNODB Specific options ***********innodb_buffer_pool_size = 2048Mtransaction-isolation=REPEATABLE-READinnodb_buffer_pool_instances = 8innodb_file_per_table = 1innodb_data_home_dir = /data/mysqldata/3306/innodb_tsinnodb_data_file_path = ibdata1:2048M:autoextendinnodb_thread_concurrency = 8innodb_log_buffer_size = 16Minnodb_log_file_size = 128Minnodb_log_files_in_group = 3innodb_log_group_home_dir = /data/mysqldata/3306/innodb_loginnodb_flush_log_at_trx_commit = 2innodb_max_dirty_pages_pct = 70innodb_flush_method=O_DIRECT[mysql]no-auto-rehashdefault-character-set=gbkprompt = (\u@\h) [\d]>\_
初始化MySQL数据库
$/usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --initialize --user=mysql
启动mysql服务
$/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf --user=mysql &
登陆数据库
备注:密码来自于error log日志,明细如下:
2018-05-16T07:17:57.335486Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jlocal/mysql/bin/mysql -uroot -p'j
数据库一些基本权限配置
修改root账号密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH sha256_password BY 'zsd@7101' PASSWORD EXPIRE INTERVAL 360 DAY;
查看目前的用户账号
(root@localhost) [(none)]> select user,host from mysql.user;+------------------+-----------+| user | host |+------------------+-----------+| mysql.infoschema | localhost || mysql.session | localhost || mysql.sys | localhost || root | localhost |+------------------+-----------+
关于“CentOS7怎么编译安装MySQL 8.0”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“CentOS7怎么编译安装MySQL 8.0”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注编程网行业资讯频道。