MySQL源码安装

发布时间:2020-08-11 14:35:12 作者:xj951423274
来源:ITPUB博客 阅读:147

1,下载源码安装包

http://dev.mysql.com/downloads/mysql/           Source Code

https://cmake.org/download/                   5.5后版本需用cmake编译

mysql-5.7 需要

-DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=/data/boost_1_59_0 

yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*

CentOS7  磁盘扩容文件系统为xfs 最后LV扩容后重新识别使用xfs_growfs

2,解压安装.tar.gz

tar zxvf cmake-3.4.1.tar.gz      

cd cmake-3.4.1

./configure

make

make install

tar –xvfz  mysql-5.6.28.tar.gz

cmake  .  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  \

-DDEFAULT_CHARSET=utf8  \

-DDEFAULT_COLLATION=utf8_general_ci   \

-DWITH_INNOBASE_STORAGE_ENGINE=1  \

-DWITH_FEDERATED_STORAGE_ENGINE=1       \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1  \

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1  \

-DWITH_PARITION_STORAGE_ENGINE=1  \

-DWITH_READLINE=ON  \

-DEXTRA_CHARSETS=all  \

-DMYSQL_DATADIR=/usr/local/mysql/data  \

-DSYSCONFDIR=/data/3306 \

-DMYSQL_UNIX_ADDR=/data/3306/mysql.sock \

-DENABLED_LOCAL_INFILE=1

  make && make install

 

3,建用户和目录

groupadd  mysql

useradd -r -g  mysql  mysql

mkdir -p /usr/local/mysql

chown  -R mysql:mysql /usr/local/mysql

mkdir -p /usr/local/mysql/data

mkdir -p /data/{3306/{data,tmp,binlog},backup,scripts}

chown -R mysql:mysql  /data

4,设置用户系统资源限制

 vi  /etc/security/limits.conf

mysql                   soft               nproc           2047

mysql                   hard              nproc            16384

mysql                  soft               nofile            1024

mysql                   hard              nofile            65536

 

5,初始化参数文件

vi /data/3306/my.cnf

[client]

port = 3306

socket = /data/3306/mysql.sock

 

#The MYSQL SERVER

[mysqld]

port = 3306

user = mysql

server-id = 111111

socket = /data/3306/mysql.sock

pid-file = /data/3306/mysql.pid

basedir = /usr/local/mysql

datadir = /data/3306/data

tmpdir = /data/3306/tmp

open_files_limit = 10240

explicit_defaults_for_timestamp

sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

#BUFFER

max_allowed_packet = 256M

max_heap_table_size = 256M

net_buffer_length = 8K

sort_buffer_size = 2M

join_buffer_size = 4M

read_buffer_size = 2M

read_rnd_buffer_size = 16M

 

#log

log-bin = /data/3306/binlog/mysql-bin

binlog_cache_size = 32m

max_binlog_cache_size = 512m

max_binlog_size = 512m

binlog_format = mixed

log_output = FILE

log-error = ../mysql-error.log

slow_query_log = 1

slow_query_log_file = ../slow_query.log

general_log = 0

general_log_file = ../general_query.log

expire-logs-days = 14

 

#InnoDB

innodb_data_file_path = ibdata1:2048M:autoextend

innodb_log_file_size = 256M

innodb_log_files_in_group = 3

innodb_buffer_pool_size = 1024M

 

[mysql]

no-auto-rehash

prompt         = (\u@\h)[\d]\_

default-character-set = utf8

 

6,初始化MYSQL数据库

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql   --datadir=/data/3306/data

 

7,启动数据库服务

cp  support-files/mysql.server  /etc/init.d/mysql

service  mysql  start  #若启动不成功,查看是哪个my.cnf启动的

./mysqld_safe --defaults-file=/data/3306/my.cnf

推荐阅读:
  1. MySQL5.5源码安装
  2. 源码安装与卸载mysql

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql 安装 源码

上一篇:iptables上课内容

下一篇:解决织梦上传服务器后数据连接失败的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》