Linux安装mysql8压缩包版本
下载mysql8
1 | https://dev.mysql.com/downloads/mysql/ |
安装依赖工具
1 | apt install xz-utils -y |
解压缩
1 | xz -dk mysql-8.0.39-linux-glibc2.28-x86_64.tar.xz |
创建mysql数据目录
1 | mkdir /usr/local/mysql/data |
编写配置文件
vim /etc/my.cnf1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[mysqld]
#
# 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
#
# 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
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
skip-host-cache
skip-name-resolve
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysqld/mysqld.sock
secure-file-priv=/usr/local/mysql/mysql-files
user=mysql
pid-file=/usr/local/mysql/mysqld/mysqld.pid
[client]
socket=/usr/local/mysql/mysqld/mysqld.sock
!includedir /usr/local/mysql/conf.d/
vim /usr/local/mysql/conf.d/mysqld.conf1
2
3
4
5
6
7
8[mysqld]
bind-address = 0.0.0.0
max_connections=2000
#binlog_format=ROW
#binlog_row_image=full
#binlog_expire_logs_seconds=15552000
#expire_logs_days=180
#server_id=1
创建启动用户与授权
1 | groupadd mysql |
初始化mysql
1 | /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ |
设置开机启动
1 | ln -s /usr/local/mysql/ /usr/bin/ |
编写服务配置
vim /etc/systemd/system/mysqld.service1
2
3
4
5
6
7
8
9
10
11
12
13
14[Unit]
Description=MySQL Community Server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
User=mysql
Group=mysql
Restart=always
[Install]
WantedBy=multi-user.target
重新加载配置1
systemctl daemon-reload
启动mysql1
systemctl start mysqld
设置开启服务1
systemctl enable mysqld
停止mysql [可选]1
systemctl stop mysqld
本文标题:Linux安装mysql8压缩包版本
本文链接:https://xxzkid.github.io/2024/linux-install-mysql8-zip/