二进制安装
下载安装包
下载mysql二进制安装包
yum -y install lrzsz numactl
wget http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-test-5.7.38-linux-glibc2.12-x86_64.tar.gz
解压
tar -zxvf mysql-test-5.7.38-linux-glibc2.12-x86_64.tar.gz
移动解压完成的mysql
mv mysql-test-5.7.38-linux-glibc2.12-x86_64 /data/mysql
cd /data
useradd -M -s /sbin/nologin mysql
mkdir /data/mysql/data/
mkdir /data/mysql/relay
chown mysql:mysql -R mysql
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/data/mysql/bin
配置my.cnf
[mysqld]
plugin-load-add=validate_password.so
validate-password=FORCE_PLUS_PERMANENT
server-id=1
user=mysql
character_set_server=utf8
init_connect='SET NAMES utf8'
read_only = 1
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay-log = slave-relay-bin
slave_skip_errors=1062
slave-net-timeout = 20
innodb_flush_log_at_trx_commit=2
master_info_repository=table
relay_log_info_repository=TABLE
log_bin=/data/mysql/mysql-bin
basedir =/data/mysql
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid
relay-log=/data/mysql/relay/relay1-log-bin
relay-log-index=/data/mysql/relay/slave-relay1-bin.index
log-slave-updates
symbolic-links=0
sync_binlog = 1max_connections = 20000
max_connect_errors = 2000
back_log =1024
wait_timeout=100
interactive_timeout=7200
key_buffer_size=128M
query_cache_size=256M
query_cache_type=1
max_connect_errors=20
sort_buffer_size=2M
max_allowed_packet=32M
join_buffer_size=2M
thread_cache_size = 300
innodb_buffer_pool_size= 2048M
innodb_flush_log_at_trx_commit =2
innodb_thread_concurrency = 0
innodb_log_buffer_size=32M
innodb_log_file_size = 50M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
binlog_cache_size = 2M
max_binlog_cache_size = 8M
max_binlog_size= 512M
expire_logs_days = 7
explicit_defaults_for_timestamp=true
检测是否可以启动mysql
/data/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize
/data/mysql/bin/mysqld --defaults-file=/data/my.cnf --user=mysql &
查看密码
cat /data/mysql/mysqld.log|grep pass
设置快速启动和停止
cat start.sh
/data/mysql/bin/mysqld --defaults-file=/data/my.cnf --user=mysql &
------------
cat stop.sh
mysqladmin shutdown -uroot -p123456
使用docker进行安装
安装docker
https://blog.csdn.net/weixin_44932410/article/details/105068767
开始启动:
docker run --name mysql -e MYSQL_ROOT_PASSWORD=123123@123 -v /data/mysql:/var/lib/mysql -it -p 3306:3306 -d docker.mirrors.sjtug.sjtu.edu.cn/library/mysql:5.7.44
docker启动名字 密码 持久化的路径前面的本地后面的容器的