虚拟机:centos 7 ip:192.168.137.128
mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz https://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
useradd mysql -s /sbin/nologin
tar -zxf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.31-linux-glibc2.12-x86_64 mysql
my.cnf配置文件参考
[mysql]
port=3306
socket=/usr/local/mysql/mysql.sock
default-character-set=utf8
[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.error
[mysqld]
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
pid-file=/usr/local/mysql/mysql.pid
character-set-server=utf8
skip-name-resolve
lower_case_table_names=1
query_cache_size=0
transaction_isolation=READ-COMMITTED
tmp_table_size=128M
max_heap_table_size=96M
max_connections=1000
max_connect_errors=6000
long_query_time=1
innodb_buffer_pool_size=2G
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=8M
innodb_log_file_size=128M
innodb_log_files_in_group=2
innodb_file_per_table=1
innodb_flush_method=O_DIRECT
innodb_file_format=Barracuda
innodb_write_io_threads=8
innodb_read_io_threads=4
innodb_doublewrite=0
innodb_purge_threads=1
innodb_stats_on_metadata=OFF
innodb_io_capacity=1000
log-bin-trust-function-creators=1
event_scheduler=on
chown mysql:mysql mysql -R
/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
修改basedir和datadir
./mysql.server start
./mysql -S/usr/local/mysql/mysql.sock -uroot -p
ALTER USER USER() IDENTIFIED BY ‘密码‘;
flush privileges; # 刷新mysql表授权
到此,mysql二进制安装完成!
原文:https://www.cnblogs.com/chenppp/p/13341934.html