博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos安装mysql more_CentOS7 安装MySQL5.6
阅读量:5013 次
发布时间:2019-06-12

本文共 4465 字,大约阅读时间需要 14 分钟。

CentOS7 安装MySQL5.6

1. 安装依赖包

yum -y install libaio autoconf numactl.x86_64

2. 创建一个mysql用户和组

groupadd -g 1055 mysql

useradd -r -u 1055 -g mysql -s /bin/false mysql

3. 创建数据目录和log目录

mkdir -p /data/.storage/mysql/50200

mkdir -p /data/log/sys/mysql

chown -R mysql.mysql /data/log/sys/mysql

4. 下载、解压mysql

cd /usr/local

wget -c https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz

tar xf mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz

ln -s mysql-5.6.45-linux-glibc2.12-x86_64 mysql

cd mysql

scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/.storage/mysql/50200/

export PATH=$PATH:/usr/local/mysql/bin

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

source /etc/profile

5. systemctl启动配置

# vim /etc/systemd/system/mysql50200.service

[Unit]

Description=mysql50200

Documentation=man:mysqld(8)

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network-online.target rsyslog.target

[Service]

User=mysql

Group=mysql

PIDFile=/data/.storage/mysql/50200/pid.pid

ExecStart=/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/etc/50200.mysql.conf --user=mysql

PrivateTmp=true

LimitNOFILE=infinity

[Install]

WantedBy=multi-user.target

6. 50200.mysql.conf配置文件

[client]

port = 50200

server-id = 50200

socket = /data/.storage/mysql/50200/sock.sock

[mysqld]

port = 50200

datadir = /data/.storage/mysql/50200

socket = /data/.storage/mysql/50200/sock.sock

pid-file = /data/.storage/mysql/50200/pid.pid

server-id = 999991

log-bin = 50200-bin

binlog-format = mixed

skip-name-resolve

back_log = 3000

#InnoDB设置

innodb_use_native_aio = 0

innodb_buffer_pool_size = 512M

innodb_thread_concurrency = 16

innodb_log_buffer_size = 8M

innodb_flush_log_at_trx_commit = 2

innodb_log_file_size = 48M

innodb_file_per_table = 1

#innodb_force_recovery = 1

skip-external-locking

explicit_defaults_for_timestamp = 1

local-infile = 0

max_connections = 3000

max_connect_errors = 100

key_buffer_size = 256M

query-cache-type = 1

query_cache_size = 64M

max_allowed_packet = 8M

thread_stack = 256K

thread_cache_size = 64

query_cache_limit = 16M

sort_buffer_size = 8M

join_buffer_size = 8M

read_buffer_size = 8M

read_rnd_buffer_size = 8M

myisam_sort_buffer_size = 16M

tmp_table_size = 256M

max_heap_table_size = 64M

connect_timeout = 60

#fix mysql gone away

wait_timeout = 10

interactive-timeout = 600

# log

general-log = 0

slow_query_log = 1

long_query_time = 2

log-queries-not-using-indexes

general-log-file = /data/log/sys/mysql/50200_gen.log

slow-query-log-file = /data/log/sys/mysql/50200_slow.log

log-error = /data/log/sys/mysql/50200_error.log

expire_logs_days = 4

[mysqldump]

max_allowed_packet = 100M

[mysql]

no-auto-rehash

default_character_set = utf8

[myisamchk]

key_buffer_size = 512M

sort_buffer_size = 256M

read_buffer_size = 8M

read_rnd_buffer_size = 32M

write_buffer_size = 256M

[mysqlhotcopy]

interactive-timeout

7. 启动mysql

systemctl daemon-reload

systemctl start mysql50200

systemctl stop mysql50200

systemctl start mysql50200

8. 报错处理

(1) 初始化报错

# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/.storage/mysql/50200/

FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db:

Data::Dumper

解决方法 :安装autoconf库

命令:yum -y install autoconf

# scripts/mysql_install_db --user=mysql

Use of uninitialized value in chown at scripts/mysql_install_db line 705.

Use of uninitialized value in chown at scripts/mysql_install_db line 705.

Use of uninitialized value in chown at scripts/mysql_install_db line 705.

Use of uninitialized value in chown at scripts/mysql_install_db line 705.

Use of uninitialized value in chown at scripts/mysql_install_db line 705.

Use of uninitialized value in chown at scripts/mysql_install_db line 705.

Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

解决方法:创建用户并安装libnuma.so.1

命令:

yum -y install libaio numactl.x86_64

groupadd -g 1055 mysql

useradd -r -u 1055 -g mysql -s /bin/false mysql

Installing MySQL system tables...2019-08-13 11:25:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details)

初始化时不影响安装:

解决方法:

在my.cnf中加入

[mysqld]

explicit_defaults_for_timestamp=true

参考链接:

下载网址: https://dev.mysql.com/downloads/mysql/

安装文档: https://dev.mysql.com/doc/refman/5.6/en/binary-installation.html

转载地址:http://koggp.baihongyu.com/

你可能感兴趣的文章
Windows 2008 R2系统开机时如何不让Windows进行磁盘检测?
查看>>
WP7应用开发笔记(18) 本地化与多语言
查看>>
解决 .so文件64与32不兼容问题
查看>>
归并排序法
查看>>
【剑指offer】面试题26:复杂链表的复制
查看>>
spark开发生成EXE
查看>>
Vue 全家桶介绍
查看>>
WPF Bitmap转Imagesource
查看>>
Java compiler level does not match the version of the installed Java project facet.解决方法
查看>>
笔记_小结
查看>>
Linux lsof命令 umount U盘
查看>>
自定义Font
查看>>
linux svn 服务端搭建
查看>>
maven用途、核心概念、用法、常用参数和命令、扩展
查看>>
linux时间同步ntp服务的安装与配置
查看>>
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法...
查看>>
网络编程-socket并发-粘包问题
查看>>
python 中安装pandas
查看>>
Hibernate 的<generator class="native"></generator>的不同属性含义
查看>>
linux修改root账户的用户名所得的教训
查看>>