暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

1

One 2024-10-14
68

mkdir -p /data/mysql/mysql_3356/{data,binlog,tmp}


chown -R mysql. /data/mysql/mysql_3356/



初始化
/usr/local/mysql56/scripts/mysql_install_db --defaults-file=/data/mysql/mysql_3356/my_3356.cnf --lower-case-table-names=1 --basedir=/usr/local/mysql56 --user=mysql

启动
/usr/local/mysql56/bin/mysqld_safe --defaults-file=/data/mysql/mysql_3356/my_3356.cnf &


修改root密码
set password for root@localhost = password('123');



cat >/data/mysql/mysql_3356/my_3356.cnf <<EOF
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
port = 3356
socket = /data/mysql/mysql_3356/tmp/mysql_3356.sock


[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
server-id=33061
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

basedir = /usr/local/mysql56
datadir = /data/mysql/mysql_3356/data

log_bin=/data/mysql/mysql_3356/binlog/mysql-bin
binlog_format=row
expire_logs_days = 7

max_connections = 1024
max_connect_errors = 1000000

port = 3356

lower_case_table_names=1
log_slow_admin_statements = 1
log_slow_slave_statements = 1

socket = /data/mysql/mysql_3356/tmp/mysql_3356.sock
slow_query_log = 1
slow_query_log_file = /data/mysql/mysql_3356/data/slow.log
log-error = /data/mysql/mysql_3356/data/error.log
long_query_time = 0.1

sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G

log_slave_updates


# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
EOF





配置开机自启动
cat >/usr/lib/systemd/system/mysql56.service <<EOF
[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
ExecStart=/usr/local/mysql56/bin/mysqld_safe --defaults-file=/data/mysql/mysql_3356/my_3356.cnf
LimitNOFILE = 5000
EOF


二、添加权限
chmod 755 /usr/lib/systemd/system/mysql56.service

三、重新加载daemon
systemctl daemon-reload

四、开机自动启动
systemctl enable mysql56.service


五、关闭数据库
mysqladmin -uroot -p shutdown

六、启动
systemctl start mysql56.service

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论