mysql 安装 se_MySQL-安装数据库(Linux)

1. 安装前环境配置

1)关闭防火墙

-- service版本

service iptables stop

chkconfig off iptables

-- systemctl版本

systemctl stop firewalld.service

systemctl disable firewalld.service

2)关闭selinux

# 禁用selinux,配置/etc/sysconfig/selinux,修改SELINUX项为disabled

if [[ "$(getenforce)" = "Enforcing" ]]; then

cp /etc/selinux/config{,_$(date +%Y%m%d)} && setenforce 0 && sed -i "/^(SELINUX=.*)/c\#/1\nSELINUX=disable" /etc/selinux/config

fi

3)配置操作系统句柄参数限制

cat > /etc/security/limits.d/99-mysql.conf <

mysql soft nproc 65536

mysql hard nproc 65536

mysql soft nofile 65536

mysql hard nofile 65536

EOF

4)创建mysql系统用户

groupadd -r mysql

useradd -r -g mysql -c "Mysql server" -s /sbin/nologin -M mysql

2. 软件安装

2.1 安装系统依赖包

2.2 安装MySQL软件

1)rpm包安装

2)二进制分发包安装

3) 源码编译安装方式

3. 初始化

4. 启动服务

1) 参数文件(my.cnf/my.ini)配置

-- 示例

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

[client]

default-character-set =utf8

socket= /usr/local/mysql57/logs/mysql.sock

[mysqld]

basedir= /usr/local/mysql57

datadir= /usr/local/mysql57/data

log-error = /usr/local/mysql57/logs/err.log

pid-file = /usr/local/mysql57/logs/mysqld.pid

socket= /usr/local/mysql57/logs/mysql.sock

port= 3308default-storage-engine =INNODB

character-set-server =utf8

collation-server =utf8_general_ci

binlog_format=ROW

log_bin= /usr/local/mysql57/data/binlogs/b3308

expire_logs_days= 3max_binlog_size=100m

max_connect_errors= 5max_connections= 1000max_user_connections= 1000wait_timeout= 1000open_files_limit= 1024local-infile = 0skip_name_resolve=ON

server_id= 3308001master_info_repository=TABLE

relay_log_info_repository=TABLE

innodb_buffer_pool_dump_at_shutdown= 1innodb_buffer_pool_load_at_startup= 1log_timestamps=SYSTEM

# undo tablespace

innodb_undo_tablespaces=3#设置为3个

innodb_undo_logs=128#默认128个

innodb_undo_directory= ./# gtid_mode

gtid_mode=on

enforce_gtid_consistency=on

log_slave_updates=ON

sync_binlog=1relay_log= /usr/local/mysql57/data/binlogs/s3308

[mysqldump]

quick

max_allowed_packet=16M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size=20M

sort_buffer_size=20M

read_buffer=2M

write_buffer=2M

[mysqlhotcopy]

interactive-timeout

View Code

2) 配置服务

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

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

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

Type=forking

PIDFile=/usr/local/mysql57/logs/mysqld.pid

TimeoutSec=0PermissionsStartOnly=trueExecStart=/usr/local/mysql57/bin/mysqld --daemonize --pid-file=/usr/local/mysql57/logs/mysqld.pid $MYSQLD_OPTS

EnvironmentFile=-/etc/sysconfig/mysql

LimitNOFILE= 10000Restart=on-failure

RestartPreventExitStatus=1PrivateTmp=false

View Code

5. 服务启动后配置

1) 修改root密码

2)用户授权

6. 删除旧版本rpm方式安装的软件(可选)

# 检查

rpm-qa |grep -E "mariadb|mysql"# 若存在,则卸载,

rpm-e --nodeps mariadb-libs

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值