关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

centos编译安装mysql5.7并指定用户运行

发布时间:2019-10-11 13:14:34

 我们今天来编译安装mysql5.7,mysql目录/ home / mysql,数据目录/ home / mysql / data,有些人喜欢放到/ usr / local / mysql,当然你也可以自定义,相当方便的,测试环境为centos6.10 64位
MySQL版本:5.7.24你也可以去官方下载最新版本:https://dev.mysql.com/downloads/mysql/5.7。 html#downloads 
下载boost版本:1.59.0,位置:https://sourceforge.net/projects/boost/files/boost/,boost安装于/ usr / local / boost 
安装支持组件:yum -y install wget gcc gcc -c ++ autoconf automake zlib * fiex * libxml * ncurses-devel libmcrypt * libtool-ltdl-devel * make cmake libaio libaio-devel autoconf bzr bison libtool 
wget --no-check-certificate https://nchc.dl.sourceforge.net /project/boost/boost/1.59.0/boost_1_59_0.tar.gz 
wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.24.tar.gz 
tar -xzvf boost_1_59_0.tar.gz 
mkdir -p / home / mysql /
mv boost_1_59_0 / home / mysql 
cd / home / mysql 
mv boost_1_59_0 boost 
cd / root 
groupadd -r mysql 
useradd -g mysql -r -M -s / sbin / nologin mysql 
mkdir -p / home / mysql  
chown -R mysql:mysql / home / mysql 
tar -zxvf mysql-5.7.24.tar.gz 
cd mysql-5.7.24 
cmake -DCMAKE_INSTALL_PREFIX = / home / mysql -DDEFAULT_CHARSET = utf8 -DDEFAULT_COLLATION = utf8_general_ci -DWITH_MYISAM_STORAGE_ENGS = 1 = -DWITHDIVE DWITH_BLACKHOLE_STORAGE_ENGINE = 1 -DWITH_MEMORY_STORAGE_ENGINE = 1 -DWITH_READLINE = 1 -DENABLED_LOCAL_INFILE = 1 -DMYSQL_USER = mysql的-DMYSQL_TCP_PORT = 3306 -DWITH_BOOST = /家庭/ MySQL的/升压/ 
让&& make install的
初始化
CD /家庭/ MySQL的/ bin中
./mysqld --initialize --user = mysql --basedir = / home / mysql --datadir = / home / mysql / data 
这时会产生一个密码-记下来,这个是root密码
vi / etc / my。 CNF 
添加或修改下面的代码
[客户] 
端口= 3306 
插座= /tmp/mysql.sock 
默认字符集= utf8mb4 
的[mysqld] 
端口= 3306 
插座= /tmp/mysql.sock 
BASEDIR = /家庭/ MySQL的
DATADIR = / home / mysql / data 
pid-file = /home/mysql/data/mysql.pid 
user = mysql 
bind-address = 0.0.0.0 
server-id = 1 
init-connect ='设置名称utf8mb4'character 
-set-server = utf8mb4 
#跳过名称解析
#跳过网络
back_log = 300 
max_connections = 1000 
max_connect_errors = 6000
open_files_limit = 65535 
table_open_cache = 128 
max_allowed_packet的= 4M 
binlog_cache_size = 1M 
max_heap_table_size = 8M 
tmp_table_size的= 16M 
read_buffer_size = 2M 
read_rnd_buffer_size = 8M 
sort_buffer_size的值= 8M 
join_buffer_size = 8M 
的key_buffer_size = 4M 
thread_cache_size的= 8 
query_cache_type的= 1 
query_cache_size变量= 8M 
query_cache_limit = 2M 
的ft_min_word_len = 4 
log_bin = mysql-bin 
binlog_format =混合
expire_logs_days = 30 
log_error = /home/mysql/data/mysql-error.log 
slow_query_log = 1 
long_query_time = 1 
slow_query_log_file = /home/mysql/data/mysql-slow.log
performance_schema = 0 
explicit_defaults_for_timestamp 
#lower_case_table_names = 1 
跳过外部锁定
default_storage_engine = InnoDB的
#默认存储引擎= MyISAM的
innodb_file_per_table = 1 
innodb_open_files = 500 
innodb_buffer_pool_size = 64M 
innodb_write_io_threads = 4 
innodb_read_io_threads = 4 
innodb_thread_concurrency参数= 0 
innodb_purge_threads = 1 
的innodb_flush_log_at_trx_commit = 2 
innodb_log_buffer_size = 2M 
innodb_log_file_size = 32M 
innodb_log_files_in_group = 3 
innodb_max_dirty_pages_pct = 90 
innodb_lock_wait_timeout = 120 
bulk_insert_buffer_size = 8M 
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G 
myisam_repair_threads = 1 
interactive_timeout = 28800 
WAIT_TIMEOUT = 28800 
[mysqldump的] 
快速
max_allowed_packet的= 16M 
[myisamchk的] 
的key_buffer_size = 8M 
sort_buffer_size的值= 8M 
的read_buffer = 4M 
write_buffer = 4M 
保存退出
加入系统-启动
CP /家/ MySQL的/支撑文件/ MySQL的.server /etc/init.d/mysqld 
chmod 755 /etc/init.d/mysqld  
chkconfig- 

配置环境变量上添加mysqld  chkconfig mysqld :echo'export  
PATH = $ PATH:/ home / mysql / bin /'>> / etc / profile 
强制
源/ etc / profile 
启动mysql 
服务mysqld start 重新启动
mysql 
服务mysqld restart
停止mysql 
服务mysqld stop


/template/Home/Zkeys/PC/Static