MySQL 环境
大约 2 分钟
MySQL 环境
1 Downloads
https://downloads.mysql.com/archives/community/
Compressed TAR Archive | MD5 |
---|---|
mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz | 5be32f68d6859aace1eb61cea1d00bff |
mysql-test-8.0.28-linux-glibc2.12-x86_64.tar.xz | 1aa16282acb18eb7cc74ea024989058b |
# powershell
$ Get-FileHash .\mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz -Algorithm MD5
Algorithm Hash Path
--------- ---- ----
MD5 5BE32F68D6859AACE1EB61CEA1D00BFF D:\下载2\linux-downloads\mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
2 安装
官方文档: https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
$ groupadd mysql
$ useradd -r -g mysql -s /bin/false mysql
$ cd /usr/local
$ tar xvf /path/to/mysql-VERSION-OS.tar.xz
$ ln -s full-path-to-mysql-VERSION-OS mysql
$ cd mysql
$ mkdir mysql-files
$ chown mysql:mysql mysql-files
$ chmod 750 mysql-files
$ bin/mysqld --initialize --user=mysql
$ bin/mysql_ssl_rsa_setup
$ bin/mysqld_safe --user=mysql &
# Next command is optional
$ cp support-files/mysql.server /etc/init.d/mysql.server
qR1e8UUr&d7n
# 缺少依赖
$ sudo apt install libaio-dev
$ sudo apt install libtinfo5
$ passwd root
# Host 'x.x.x.x' is not allowed to connect to this MySQL server 问题
mysql -u root -h 192.168.183.216 -p --get-server-public-key
alter user 'root'@'localhost' identified by 'mysql123';
select host from user where user = 'root';
update user set host = '%' where user = 'root';
flush privileges;
# 主备环境 https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html
mysql> show master status \G
*************************** 1. row ***************************
File: binlog.000003
Position: 7681
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.01 sec)
CHANGE MASTER TO MASTER_HOST = '192.168.183.216', MASTER_USER = 'root', MASTER_PASSWORD = 'mysql123', MASTER_PORT = 3306, MASTER_LOG_FILE = 'binlog.000003', MASTER_LOG_POS = 11448;
start slave;
show slave status;
Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'mysql123';
error connecting to master 'root@192.168.183.216:3306' - retry-time: 60 retries: 1 message: Access denied for user 'root'@'192.168.183.171' (using password: YES)
The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
service mysqld restart
Initialization of the server's UUID failed because it could not be read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to generate a new UUID.
The designated data directory /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64/data/ is unusable. You can remove all files that the server added to it.
Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
show variables like '%server_uuid%';
show variables like '%server_id%';
SET GLOBAL server_id=2;
Windows:
# 初始化
PS D:\programs\mysql-5.7.39-winx64\bin> .\mysqld.exe --initialize
# 启动服务
PS D:\programs\mysql-5.7.39-winx64\bin> .\mysqld.exe
3 MTR (mysql-test-run)
# 解压
$ tar xvf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
$ tar xvf mysql-test-8.0.28-linux-glibc2.12-x86_64.tar.xz
$ cd mysql-8.0.28-linux-glibc2.12-x86_64/mysql-test/t/
$ vi mytest.test
$ cd ..
$ ./mtr --record mytest.test
Logging: ./mtr --record mytest.test
MySQL Version 8.0.28
Checking supported features
Using 'all' suites
Collecting tests
Removing old var directory
Creating var directory '/home/admin0/Downloads/mysql-8.0.28-linux-glibc2.12-x86_64/mysql-test/var'
Installing system database
Using parallel: 1
==============================================================================
TEST NAME RESULT TIME (ms) COMMENT
------------------------------------------------------------------------------
[ 50%] main.mytest [ pass ] 22
[100%] shutdown_report [ pass ]
------------------------------------------------------------------------------
The servers were restarted 0 times
The servers were reinitialized 0 times
Spent 0.022 of 8 seconds executing testcases
Completed: All 2 tests were successful.
(全文完)