1、进入到安装目录
cd /opt/sudytech/
上传安装包
mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
解压
tar -xzvf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
改名
mv /opt/sudytech/mysql-5.7.34-linux-glibc2.12-x86_64 /opt/sudytech/mysql
修改配置文件
vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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 = 3306
socket = /opt/sudytech/mysql/stat/pid/mysql.sock
[mysqld]
character-set-server = utf8mb4
skip_name_resolve = 1
user = mysql
port = 3306
basedir = /opt/sudytech/mysql/
datadir = /opt/sudytech/mysql/data
innodb_data_home_dir = /opt/sudytech/mysql/data
socket = /opt/sudytech/mysql/stat/pid/mysql.sock
pid-file = /opt/sudytech/mysql/stat/pid/mysql.pid
log-error = /opt/sudytech/mysql/stat/logs/log-error.log
slow-query-log-file=/opt/sudytech/mysql/stat/logs/slow.log
relay-log-index = /opt/sudytech/mysql/stat/logs/relaylog
relay-log-info-file = /opt/sudytech/mysql/stat/logs/relaylog
relay-log = /opt/sudytech/mysql/stat/logs/relaylog
open_files_limit = 10240
table_open_cache = 2048
back_log = 300
max_connections = 10000
max_connect_errors = 20
explicit_defaults_for_timestamp = 1
max_allowed_packet = 64M
thread_cache_size = 300
query_cache_size = 256M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = InnoDB
thread_stack = 512K
transaction_isolation = READ-COMMITTED
tmp_table_size = 256M
max_heap_table_size = 256M
key_buffer_size = 2G
sort_buffer_size = 2M
join_buffer_size = 6M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 15G
myisam_repair_threads = 1
interactive_timeout = 1800
wait_timeout = 28800
innodb_data_file_path = ibdata1:100M;ibdata2:100M;ibdata3:100M:autoextend
innodb_buffer_pool_size = 6G
innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_purge_threads = 0
slow_query_log = 1
long_query_time = 3
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
#slave-skip-errors = 1032,1062,1026,1114,1146,1048,1396
server-id = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysqldump]
quick
max_allowed_packet = 64M
新建目录
mkdir -p /opt/sudytech/mysql/stat/pid
mkdir -p /opt/sudytech/mysql/stat/logs
adduser -s /sbin/nologin mysql
设置密码
passwd mysql
授予运行权限
chown -R mysql /opt/sudytech/mysql
安装依赖,否则进行数据库初始化的时候会报错
yum install libaio* -y
初始化时,需保证无mysql进程、且mysql/data目录内为空;只使用–initialize初始化,则将在log-error.log中生成随机密码
/opt/sudytech/mysql/bin/mysqld --initialize-insecure
启动进程
/opt/sudytech/mysql/bin/mysqld_safe &
(管理员密码修改)
/opt/sudytech/mysql/bin/mysqladmin -u root password '123456'
进入数据库
/opt/sudytech/mysql/bin/mysql -u root -p123456
成功进入
打开个人电脑上的navicat,测试是否可以正常连接
新建一个数据库vhr