暂无图片
暂无图片
2
暂无图片
暂无图片
暂无图片

MySQL 8.0二进制安装

MySQL 8.0二进制安装

下载MySQL二进制包

官网地址,下载MySQL:https://dev.mysql.com/
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

这里强调一点,进入下载软件包的系统平台选择页面,我们这里选择 Linux - Generic,版本选择x86-64。
还有要注意的,下载之前其他版本:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
会有以下几个版本:
1)GA:Generally Available(GA) Release
2)DMR: Development Releases
3)RC: Release candidate
4)Beta: Public Beta befor final release
5)alpha
生产或者测试环境选择GA版本,常规可用版本,经过bug修复测试过的正式发行版。其余都是测试版。
下载完成后,上传软件包,注意校验md5码。
在这里插入图片描述

操作系统配置

关闭selinux和防火墙

cp /etc/selinux/config /etc/selinux/config_`date +"%Y%m%d_%H%M%S"`&& sed -i 's/SELINUX\=enforcing/SELINUX\=disabled/g' /etc/selinux/config systemctl stop firewalld.service systemctl disable firewalld.service
复制

关闭numa

[root@postgre tmp]# numactl --hardware available: 1 nodes (0) node 0 cpus: 0 node 0 size: 1023 MB node 0 free: 69 MB node distances: node 0 0: 10
复制

available: 1 nodes (0) #如果是2或多个nodes就说明numa没关掉

如果命令不识别,需要安装numactl,但是本地iso里面没有这个包。如果有外网电脑,可以先下载软件,在传输到目标主机:

yum -y install numactl --downloadonly --downloaddir=/tmp/ rpm -ivh numactl-2.0.12-5.el7.x86_64.rpm
复制

关闭numa:

[root@crm3db1 ~]# cat /etc/default/grub GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rd.lvm.lv=rhel/usr rhgb quiet numa=off intel_pstate=disable"
复制

这条是针对EFI方式的grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
reboot

IO调度

下面是查看磁盘IO模式

for i in `ls /sys/block|grep -v ^loop|grep -v ^ram` do printf "%-20s %40s\n" "$i" "`cat /sys/block/${i}/queue/scheduler`" done
复制

使用deadline磁盘模式,如果是使用FC盘,可以启用磁盘的deadline模式,另外需要观察是否有其它的脚本来修改磁盘IO模式的

[root@crm3db1 ~]# cat /etc/default/grub GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rd.lvm.lv=rhel/usr rhgb quiet numa=off elevator=deadline intel_pstate=disable"
复制

永久生效

swap分区

文件系统

xfs

操作系统资源限制

echo " * soft nproc 655350 * hard nproc 655350 * soft nofile 655360 * hard nofile 655360" >>/etc/security/limits.conf
复制

安装过程

以下操作,没有特殊说明,都是在root用户下操作。
1)创建用户

groupadd mysql useradd -g mysql -s /sbin/nologin -d /usr/local/mysql -MN mysql
复制

注意:这里bash是nologin,也就是没有shell,用户不能登录bash中,提高安全性
2)解压包

cd /soft unxz mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz tar -xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar
复制
  1. 软件包的家目录(basedir)统一规范放在/usr/local 下面,做个软链接,方便日后升级
cd /usr/local ln -s /soft/mysql-8.0.27-linux-glibc2.12-x86_64 mysql
复制

解绑

cd /usr/local unllink mysql
复制

4)创建数据目录及赋权

mkdir /data/mysql/mysql3306/{data,logs,tmp} -p chown -R mysql:mysql /usr/local/mysql/ chown -R mysql:mysql /data/mysql/mysql3306/
复制

5)创建参数文件my.cnf
可以在网站上自动生成,再自己修改下:https://imysql.com/my-cnf-wizard.html
在这里插入图片描述

[root@postgre data]# cat /data/mysql/mysql3306/my3306.cnf # ## my.cnf for 8.0版本 ## author: yejr(yejinrong@zhishutang.com, http://imysql.com, QQ: 4700963) ## ## 叶金荣(yejr) ## 国内知名MySQL专家,MySQL布道师,Oracle MySQL ACE Director,腾讯云TVP成员。 ## 微信公众:老叶茶馆(imysql_wx), 博客:https://imysql.com ## QQ群: 125572178 ## 注意:个别建议可能需要根据实际情况作调整,请自行判断或联系我,本人不对这些建议结果负相应责任 ## 本配置文件主要适用于MySQL 8.0版本 # [client] port = 3306 socket = /tmp/mysql3306.sock [mysql] prompt = "\u@postgre \R:\m:\s [\d]> " no_auto_rehash [mysqld] user = mysql port = 3306 #主从复制或MGR集群中,server_id记得要不同 #另外,实例启动时会生成 auto.cnf,里面的 server_uuid 值也要不同 #server_uuid的值还可以自己手动指定,只要符合uuid的格式标准就可以 server_id = 3306 basedir = /usr/local/mysql datadir = /data/mysql/mysql3306/data socket = /tmp/mysql3306.sock pid_file = postgre.pid character_set_server = UTF8MB4 skip_name_resolve = 1 #若你的MySQL数据库主要运行在境外,请务必根据实际情况调整本参数 default_time_zone = "+8:00" #启用admin_port,连接数爆满等紧急情况下给管理员留个后门 admin_address = '127.0.0.1' admin_port = 33062 #performance setttings lock_wait_timeout = 3600 open_files_limit = 65535 back_log = 1024 max_connections = 10 max_connect_errors = 1000000 table_open_cache = 20 table_definition_cache = 40 thread_stack = 512K sort_buffer_size = 4M join_buffer_size = 4M read_buffer_size = 8M read_rnd_buffer_size = 4M bulk_insert_buffer_size = 64M thread_cache_size = 15 interactive_timeout = 600 wait_timeout = 600 tmp_table_size = 32M max_heap_table_size = 32M #log settings log_timestamps = SYSTEM log_error = /data/mysql/mysql3306/data/error.log log_error_verbosity = 3 slow_query_log = 1 log_slow_extra = 1 slow_query_log_file = /data/mysql/mysql3306/data/slow.log long_query_time = 0.1 log_queries_not_using_indexes = 1 log_throttle_queries_not_using_indexes = 60 min_examined_row_limit = 100 log_slow_admin_statements = 1 #log_slow_slave_statements = 1 log_bin = /data/mysql/mysql3306/data/mybinlog binlog_format = ROW sync_binlog = 1 #MGR环境中由其他节点提供容错性,可不设置双1以提高本地节点性能 binlog_cache_size = 4M max_binlog_cache_size = 512M max_binlog_size = 512M binlog_rows_query_log_events = 1 binlog_expire_logs_seconds = 604800 #MySQL 8.0.22前,想启用MGR的话,需要设置binlog_checksum=NONE才行 binlog_checksum = CRC32 gtid_mode = ON enforce_gtid_consistency = TRUE #myisam settings key_buffer_size = 32M myisam_sort_buffer_size = 128M #replication settings relay_log_recovery = 1 #slave_parallel_type = LOGICAL_CLOCK #slave_parallel_workers = 64 #可以设置为逻辑CPU数量的2倍 binlog_transaction_dependency_tracking = WRITESET #slave_preserve_commit_order = 1 #slave_checkpoint_period = 2 #innodb settings transaction_isolation = REPEATABLE-READ innodb_buffer_pool_size = 200M innodb_buffer_pool_instances = 1 innodb_data_file_path = ibdata1:12M:autoextend innodb_flush_log_at_trx_commit = 1 #MGR环境中由其他节点提供容错性,可不设置双1以提高本地节点性能 innodb_log_buffer_size = 32M innodb_log_file_size = 1G #如果线上环境的TPS较高,建议加大至1G以上,如果压力不大可以调小 innodb_log_files_in_group = 3 innodb_max_undo_log_size = 512M # 根据您的服务器IOPS能力适当调整 # 一般配普通SSD盘的话,可以调整到 10000 - 20000 # 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000 innodb_io_capacity = 4000 innodb_io_capacity_max = 8000 innodb_open_files = 65535 innodb_flush_method = O_DIRECT innodb_lru_scan_depth = 4000 innodb_lock_wait_timeout = 10 innodb_rollback_on_timeout = 1 innodb_print_all_deadlocks = 1 innodb_online_alter_log_max_size = 512M innodb_print_ddl_logs = 1 innodb_status_file = 1 #注意: 开启 innodb_status_output & innodb_status_output_locks 后, 可能会导致log_error文件增长较快 innodb_status_output = 0 innodb_status_output_locks = 1 innodb_sort_buffer_size = 67108864 innodb_adaptive_hash_index = OFF #innodb monitor settings innodb_monitor_enable = "module_innodb" innodb_monitor_enable = "module_server" innodb_monitor_enable = "module_dml" innodb_monitor_enable = "module_ddl" innodb_monitor_enable = "module_trx" innodb_monitor_enable = "module_os" innodb_monitor_enable = "module_purge" innodb_monitor_enable = "module_log" innodb_monitor_enable = "module_lock" innodb_monitor_enable = "module_buffer" innodb_monitor_enable = "module_index" innodb_monitor_enable = "module_ibuf_system" innodb_monitor_enable = "module_buffer_page" #innodb_monitor_enable = "module_adaptive_hash" #pfs settings performance_schema = 1 #performance_schema_instrument = '%memory%=on' performance_schema_instrument = '%lock%=on' [mysqldump] quick [root@postgre data]#
复制

6)初始化数据库
可以初始化有密码的,也可以初始化没密码的。
有密码的:

[root@postgre data]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf --initialize
复制

如果有问题,会瞬时返回。如果没错,等几分钟,返回。
日志如下:

2021-12-23T13:03:22.639093+08:00 6 [Note] [MY-011061] [Server] Creating the system database. 2021-12-23T13:03:22.639186+08:00 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: <eku.<d+q9Wt 2021-12-23T13:03:22.639264+08:00 6 [Note] [MY-011061] [Server] Creating the system tables. 2021-12-23T13:03:23.041885+08:00 6 [Note] [MY-011061] [Server] Filling in the system tables, part 1. 2021-12-23T13:03:23.135669+08:00 6 [Note] [MY-011061] [Server] Filling in the system tables, part 2. 2021-12-23T13:03:23.426357+08:00 6 [Note] [MY-011061] [Server] Filling in the mysql.help table. 2021-12-23T13:03:23.557987+08:00 6 [Note] [MY-011061] [Server] Creating the system users for internal usage. 2021-12-23T13:03:23.776475+08:00 6 [Note] [MY-011061] [Server] Creating the sys schema. 2021-12-23T13:03:25.152231+08:00 6 [Note] [MY-010456] [Server] Bootstrapping complete 2021-12-23T13:03:25.211049+08:00 0 [Note] [MY-010067] [Server] Giving 0 client threads a chance to die gracefully 2021-12-23T13:03:25.211090+08:00 0 [Note] [MY-010117] [Server] Shutting down slave threads 2021-12-23T13:03:25.211118+08:00 0 [Note] [MY-010118] [Server] Forcefully disconnecting 0 remaining clients 2021-12-23T13:03:25.214357+08:00 0 [Note] [MY-012330] [InnoDB] FTS optimize thread exiting. 2021-12-23T13:03:25.818925+08:00 0 [Note] [MY-013072] [InnoDB] Starting shutdown... 2021-12-23T13:03:25.821662+08:00 0 [Note] [MY-011944] [InnoDB] Dumping buffer pool(s) to /data/mysql/mysql3306/data/ib_buffer_pool 2021-12-23T13:03:25.821973+08:00 0 [Note] [MY-011944] [InnoDB] Buffer pool(s) dump completed at 211223 13:03:25 2021-12-23T13:03:26.350991+08:00 0 [Note] [MY-013084] [InnoDB] Log background threads are being closed... 2021-12-23T13:03:26.941053+08:00 0 [Note] [MY-012980] [InnoDB] Shutdown completed; log sequence number 17765224 2021-12-23T13:03:26.941296+08:00 0 [Note] [MY-012255] [InnoDB] Removed temporary tablespace data file: "ibtmp1"
复制

主要看有没有ERRO,一般成功后,只有NOTE和Warning。
7)启动数据库

[root@postgre data]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf &
复制

日志会有:2021-12-23T16:45:02.019906+08:00 0 [System] [MY-013292] [Server] Admin interface ready for connections, address: ‘127.0.0.1’ port: 33062
表示启动成功。 for connections.

连接数据库

改root密码

[root@postgre data]# mysql -S /tmp/mysql3306.sock -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.27 Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> mysql> mysql> mysql> alter user user() idendified by 'mysql'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'idendified by 'mysql'' at line 1 mysql> alter user user() identified by 'mysql'; Query OK, 0 rows affected (0.04 sec)
复制

连接mysql
在Linux平台环境下主要有两种连接方式:一种是TCP/IP连接方式,另一种就是Socket连接(Unix domain socket)。
TCP/IP连接是网络中用的最多的一种方式。一般情况下客户端在一台服务器上,而MySQL实例在另一台服务器上,两台机器通过一个TCP/IP网络连接。
1)mysql -uusername -ppassword -Pport -hIP
如:
[root@postgre data]# mysql -hlocalhost -P3306 -p
通过TCP/IP连接MySQL实例时,MySQL先会检查一张权限表,用来判断发起请求的客户端IP是否允许连接到MySQL实例。该表就是MySQL库下面user表。

2)unix socket连接方式其实不是一个网络协议,所以只能在MySQL客户端和数据库实例在同一台服务器上的情况下使用。可以在配置文件中指定套接字文件的路径,如socket=/tmp/mysql.sock.
mysql -uusername -p -S /tmp/mysql.sock
如:
[root@postgre data]# mysql -S /tmp/mysql3306.sock -uroot -p

官方找了一个说明此连接的图:
在这里插入图片描述
该 服务器 可以 处理 多个 客户端 连接 同时进行。 现在 让 我们 谈谈 关于 连接 的方法。 远程 连接, 必须 要 由 通过 TCP / IP。 但是, TCP / IP 可以 还 可以 用来 为 一个 本地 连接。 Unix 或 Linux 本地 连接 可以 使用 一个 的Unix 套接字 文件 或 TCP / IP。

关闭mysql
1、shutdown;

root@postgre 16:58: [(none)]> shutdown; Query OK, 0 rows affected (0.00 sec)
复制

2、mysqladmin
[]# mysqladmin -S /tmp/mysql3306.sock -p shutdown

mysqladmin [root@postgre data]# mysqladmin -S /tmp/mysql3306.sock -p shutdown Enter password: [1]+ Done strace -fr -o /tmp/1 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf [root@postgre data]# ps -ef|grep mysql root 12626 7937 0 17:00 pts/1 00:00:00 grep --color=auto mysql
复制

在这里插入图片描述

遇到问题

1、初始化遇到的问题

[root@postgre data]# cat error.log 2021-12-23T13:02:41.676061+08:00 0 [Warning] [MY-000081] [Server] option 'table_definition_cache': unsigned value 40 adjusted to 400. 2021-12-23T13:02:41.676700+08:00 0 [Note] [MY-010096] [Server] Ignoring --secure-file-priv value as server is running with --initialize(-insecure). 2021-12-23T13:02:41.676732+08:00 0 [Note] [MY-010949] [Server] Basedir set to /soft/mysql-8.0.27-linux-glibc2.12-x86_64/. 2021-12-23T13:02:41.676756+08:00 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.27) initializing of server in progress as process 9439 2021-12-23T13:02:41.678570+08:00 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2021-12-23T13:02:41.678760+08:00 0 [ERROR] [MY-013236] [Server] The designated data directory /data/mysql/mysql3306/data/ is unusable. You can remove all files that the server added to it. 2021-12-23T13:02:41.678854+08:00 0 [ERROR] [MY-010119] [Server] Aborting 2021-12-23T13:02:41.678916+08:00 0 [Note] [MY-010120] [Server] Binlog end 2021-12-23T13:02:41.679078+08:00 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.27) MySQL Community Server - GPL.
复制

报错也很明显,/data目录不为空,底下有东西,需要手动清空。
解决:

[root@postgre mysql3306]# cd /data/mysql/mysql3306/data/ [root@postgre data]# rm -rf *
复制

重新初始化:

[root@postgre data]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf --initialize-insecure
复制

此时error.log里面有明确说明:
2021-12-23T17:55:50.575825+08:00 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
由于使用了参数–initialize-insecure,所以此时mysql数据库没有密码。

[root@postgre data]# mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf & [1] 13395 [root@postgre data]# ps -ef|grep mysql mysql 13395 7937 46 17:57 pts/1 00:00:01 mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf root 13439 7937 0 17:57 pts/1 00:00:00 grep --color=auto mysql [root@postgre data]# mysql -S /tmp/mysql3306.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.27 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
复制

mysql初始化到底做了什么
general_log=1 --mysql与os交互,到底在操作系统干了什么
hostname.log

特别说明

1、mysql数据库只能以普通用户启动,root用户不能启动。像我们创建的mysql用户
在这里插入图片描述
但是我们一直是以root用户操作的,为什么还可以mysqld启动,而且启动后就是mysql用户。原因就是我们在配置文件中有参数:
在这里插入图片描述
才能启动成功,而且启动后还是mysql用户。
也可以不在配置文件中添加,启动的时候在命令行明文写入。

对上面的root启动报错做一个补充:
注释掉user=mysql
在这里插入图片描述
重新启动:
在这里插入图片描述
主要报错:
2021-12-24T10:15:22.042383+08:00 0 [ERROR] [MY-010123] [Server] Fatal error: Please read “Security” section of the manual to find out how to run mysqld as root!
可见为了安全,不让拿root用户启动。

#mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf --user=mysql
复制

2、MySQL读取配置文件的顺序,也就是优先级:
在这里插入图片描述
/etc/my.cnf–> /etc/mysql/my.cnf–> /usr/local/mysql/etc/my.cnf–> ~/.my.cnf
根据strace结果分析,mysql 8.0之后,还会加载如下配置文件。
stat("/data/mysql/mysql3306/data/mysqld-auto.cnf"
3、mysqld启动项指定配置文件有以下三种
在这里插入图片描述
–defaults-file 只加载指定位置的配置文件。
–defaults-extra-file 最后加载的配置文件。
–no-defaults 忽略所有的配置文件。

通过–print-defaults 参数查看mysqld加载的参数。
在这里插入图片描述
不在默认位置的配置文件,要输入具体配置文件路径。

4、mysql客户端也有加载配置文件的参数。
在这里插入图片描述
-defaults-file=/data/mysql/mysql3306/my3306.cnf 路径下配置了客户端的连接参数
在这里插入图片描述
但是不生效:
在这里插入图片描述
按照前面的配置文件优先级,复制一份到/etc/my.cnf,可以生效。
但是我用的是自己写的配置文件,不应该去找默认位置的,经过一番询问,原来mysql客户端也可以指定配置文件。
在这里插入图片描述

多实例安装

创建目录

[root@postgre ~]# cd /data/mysql [root@postgre mysql]# mkdir -p mysql3307/{data,logs,tmp} [root@postgre mysql]# cd mysql3307/ [root@postgre mysql3307]# ll total 0 drwxr-xr-x. 1 root root 0 Dec 24 15:19 data drwxr-xr-x. 1 root root 0 Dec 24 15:19 logs drwxr-xr-x. 1 root root 0 Dec 24 15:19 tmp [root@postgre mysql3307]# cd .. [root@postgre mysql]# ll total 0 drwxr-xr-x. 1 mysql mysql 42 Dec 24 14:27 mysql3306 drwxr-xr-x. 1 root root 22 Dec 24 15:19 mysql3307 [root@postgre mysql]# ll total 0 drwxr-xr-x. 1 mysql mysql 42 Dec 24 14:27 mysql3306 drwxr-xr-x. 1 root root 22 Dec 24 15:19 mysql3307 [root@postgre mysql]# cp mysql3306/my3306.cnf mysql3307/ [root@postgre mysql]# cd mysql3307/ [root@postgre mysql3307]# mv my3306.cnf my3307.cnf
复制

修改权限

[root@postgre mysql]# ll total 0 drwxr-xr-x. 1 mysql mysql 42 Dec 24 14:27 mysql3306 drwxr-xr-x. 1 root root 42 Dec 24 15:26 mysql3307 [root@postgre mysql]# chown mysql:mysql -R mysql3307/ [root@postgre mysql]# ll total 0 drwxr-xr-x. 1 mysql mysql 42 Dec 24 14:27 mysql3306 drwxr-xr-x. 1 mysql mysql 42 Dec 24 15:26 mysql3307 [root@postgre mysql]# cd mysql3307/
复制

修改my.cnf
只修改如下几项:

[root@postgre mysql3306]# grep 3306 my3306.cnf port = 3306 socket = /tmp/mysql3306.sock port = 3306 server_id = 3306 datadir = /data/mysql/mysql3306/data socket = /tmp/mysql3306.sock admin_port = 33062 log_error = /data/mysql/mysql3306/data/error.log slow_query_log_file = /data/mysql/mysql3306/data/slow.log log_bin = /data/mysql/mysql3306/data/mybinlog
复制

批量修改:
:%s/3306/3307/g
sed -i ‘s/3306/3307/g’ my3307.cnf

初始化

[root@postgre mysql3307]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my3307.cnf --initialize-insecure [root@postgre mysql3307]# [root@postgre mysql3307]# cat data/error.log
复制

启动:

[root@postgre mysql3306]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3307/my3307.cnf & [1] 20579 [root@postgre mysql3306]# [root@postgre mysql3306]# 2021-12-24T07:35:02.071130Z mysqld_safe Logging to '/data/mysql/mysql3307/data/error.log'. 2021-12-24T07:35:02.101658Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql3307/data [root@postgre mysql3306]# ps -ef|grep mysql mysql 18098 1 0 11:59 ? 00:00:23 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf root 20579 20236 0 15:35 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3307/my3307.cnf mysql 21788 20579 31 15:35 pts/1 00:00:02 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my3307.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3307/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/mysql3307/data/error.log --open-files-limit=65535 --pid-file=postgre.pid --socket=/tmp/mysql3307.sock --port=3307 root 21840 20236 0 15:35 pts/1 00:00:00 grep --color=auto mysql
复制

本地连接

[root@postgre data]# /usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.27 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql> exit Bye [root@postgre data]# /usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.27 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
复制

也可以在上面安装mysql5.7,只要端口不一样,同样可以启动。IP:端口 只要唯一,就可以安装启动多实例。
在这里插入图片描述

整个过程总结:
1、有mysql-package
2、创建账号,用户组
3、创建目录 /data/mysql/mysql3306/{data,logs,tmp}
4、更改权限
5、解压MySQL包
6、创建软链
7、初始化
8、启动

最后修改时间:2021-12-26 11:09:05
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论