1,环境介绍
2,去mysql官网下载包 https://dev.mysql.com/downloads/mysql/
或者 wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz
3, 解压压缩包 改名
tar xf mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.29-linux-glibc2.12-x86_64 mysql
4,创建 my.cnf 启动过程中看日志my.cnf的配置和5.7是有区别的修改修改大小参数
mkdir mysql/ect
cd mysql/ect
! 建议把socket 放在 /tmp 下,否者每次连接都要指定socket
vim my.cnf
[client]
#user=xxx
#password=xxxx
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir= /home/mysql/dbdata/data
basedir= /home/mysql
pid-file= /home/mysql/dbdata/data/mysqld_3307.pid
log-error= /home/mysql/dbdata/data/mysqld_3307.log
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
skip-name-resolve
skip-host-cache
character_set_server=utf8mb4
explicit_defaults_for_timestamp
max_allowed_packet = 16M
sort_buffer_size = 4M
read_buffer_size = 16M
#query_cache_size = 32M
#query_cache_limit = 8M
read_rnd_buffer_size = 32M
myisam_sort_buffer_size = 128M
tmp_table_size = 128M
sync_binlog = 0
binlog_format = ROW
binlog_cache_size = 4M
log-slave-updates = 1
log-bin=mysql-bin
expire_logs_days = 10
max_connections = 18096
max_user_connections = 18000
max_connect_errors = 9999999
slow_query_log=on
slow-query-log-file = slow.log
long_query_time = 5
skip-federated
server-id = 5
default-storage-engine=InnoDB
innodb_data_file_path = ibdata1:12M:autoextend
innodb_file_per_table = 1
innodb_buffer_pool_size = 100M
#innodb_buffer_pool_instances = 5
innodb_log_files_in_group = 2
innodb_log_file_size = 50M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_table_locks = 0
transaction-isolation=READ-COMMITTED
innodb_doublewrite = 0
innodb_flush_method = O_DIRECT
log_bin_trust_function_creators = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
#user=xxx
#password=xxxx
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 64M
sort_buffer_size = 32M
read_buffer = 16M
write_buffer = 16M
[mysqlhotcopy]
interactive-timeout
5,初始化数据库 并启动
mkdir /home/mysql/dbdata -p
/home/mysql/bin/mysqld --initialize-insecure --basedir=/home/mysql --datadir=/home/mysql/dbdata/data
/home/mysql/bin/mysqld_safe --defaults-file=/home/mysql/etc/my.cnf --user=root &
6,连接数据库 修改root密码
/home/mysql/bin/mysql --socket=/tmp/mysql.sock
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql!333';
7,添加环境变量
PATH="$HOME/.local/bin:$HOME/bin:/home/mysql/bin:$PATH"