已有一个OCI计算实例,Oracle Linux 7.9,1OCPU,16G内存:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 2
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 25
Model: 1
Model name: AMD EPYC 7J13 64-Core Processor
Stepping: 1
CPU MHz: 2445.406
BogoMIPS: 4890.81
Virtualization: AMD-V
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 64K
L1i cache: 64K
L2 cache: 512K
L3 cache: 16384K
NUMA node0 CPU(s): 0,1
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm rep_good nopl cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core invpcid_single ssbd ibrs ibpb stibp vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves nt_good clzero xsaveerptr wbnoinvd arat npt nrip_save umip pku ospke vaes vpclmulqdq rdpid fsrm arch_capabilities$ free -gtotal used free shared buff/cache available
Mem: 15 0 14 0 0 14
从这里获取对应Linux版本的repo文件,并安装:
curl -O https://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm
查看repo,5.7的已经启用了:
$ yum repolist enabled | grep -i mysql
mysql-connectors-community/x86_64 MySQL Connectors Community 258
mysql-tools-community/x86_64 MySQL Tools Community 108
mysql57-community/x86_64 MySQL 5.7 Community Server 696
ol7_MySQL80/x86_64 MySQL 8.0 for Oracle Linux 7 (x86 500
ol7_MySQL80_connectors_community/x86_64 MySQL 8.0 Connectors Community fo 111
ol7_MySQL80_tools_community/x86_64 MySQL 8.0 Tools Community for Ora 46
但是但是,MYSQL80的也启用了,我们需要禁止他,否则会安装8.0版本的。
sudo yum-config-manager --disable ol7_MySQL80
sudo yum-config-manager --disable ol7_MySQL80_connectors_community --disable ol7_MySQL80_tools_community
发现已经安装了一些:
$ yum list installed |grep -i mysql
mysql-community-client-plugins.x86_64 8.0.37-1.el7 @ol7_MySQL80
mysql-community-common.x86_64 8.0.37-1.el7 @ol7_MySQL80
mysql-community-libs.x86_64 8.0.37-1.el7 @ol7_MySQL80
mysql-community-libs-compat.x86_64 8.0.37-1.el7 @ol7_MySQL80
mysql-release-el7.x86_64 1.0-5.el7 @ol7_latest
卸载:
$ sudo yum remove mysql-community-client-plugins
$ sudo yum remove mysql-community-common
此时:
$ yum list installed |grep -i mysql
mysql-release-el7.x86_64 1.0-5.el7 @ol7_latest
mysql57-community-release.noarch el7-9 @/mysql57-community-release-el7-9.noarch
安装MySQL Server:
$ sudo yum install mysql-community-server
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.44-1.el7 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.44-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.44-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.44-1.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved==============================================================================================================================================================================================Package Arch Version Repository Size
==============================================================================================================================================================================================
Installing:mysql-community-server x86_64 5.7.44-1.el7 mysql57-community 184 M
Installing for dependencies:mysql-community-client x86_64 5.7.44-1.el7 mysql57-community 31 Mmysql-community-common x86_64 5.7.44-1.el7 mysql57-community 313 kmysql-community-libs x86_64 5.7.44-1.el7 mysql57-community 3.0 MTransaction Summary
==============================================================================================================================================================================================
Install 1 Package (+3 Dependent packages)Total download size: 219 M
Installed size: 930 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/mysql57-community/packages/mysql-community-common-5.7.44-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Public key for mysql-community-common-5.7.44-1.el7.x86_64.rpm is not installed
(1/4): mysql-community-common-5.7.44-1.el7.x86_64.rpm | 313 kB 00:00:00
(2/4): mysql-community-libs-5.7.44-1.el7.x86_64.rpm | 3.0 MB 00:00:00
(3/4): mysql-community-client-5.7.44-1.el7.x86_64.rpm | 31 MB 00:00:00
(4/4): mysql-community-server-5.7.44-1.el7.x86_64.rpm | 184 MB 00:00:01
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 132 MB/s | 219 MB 00:00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5Package : mysql57-community-release-el7-9.noarch (@/mysql57-community-release-el7-9.noarch)From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: yPublic key for mysql-community-server-5.7.44-1.el7.x86_64.rpm is not installedFailing package is: mysql-community-server-5.7.44-1.el7.x86_64GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
出错了,错误为:
Public key for mysql-community-server-5.7.44-1.el7.x86_64.rpm is not installed
那就导入key:
$ sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
其实有3个RPM GPG KEY,试过2023不行,才使用2022的:
再次安装,这回成功了:
$ sudo yum install mysql-community-server
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.44-1.el7 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.44-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.44-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.44-1.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved==============================================================================================================================================================================================Package Arch Version Repository Size
==============================================================================================================================================================================================
Installing:mysql-community-server x86_64 5.7.44-1.el7 mysql57-community 184 M
Installing for dependencies:mysql-community-client x86_64 5.7.44-1.el7 mysql57-community 31 Mmysql-community-common x86_64 5.7.44-1.el7 mysql57-community 313 kmysql-community-libs x86_64 5.7.44-1.el7 mysql57-community 3.0 MTransaction Summary
==============================================================================================================================================================================================
Install 1 Package (+3 Dependent packages)Total size: 219 M
Installed size: 930 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.Installing : mysql-community-common-5.7.44-1.el7.x86_64 1/4Installing : mysql-community-libs-5.7.44-1.el7.x86_64 2/4Installing : mysql-community-client-5.7.44-1.el7.x86_64 3/4Installing : mysql-community-server-5.7.44-1.el7.x86_64 4/4Verifying : mysql-community-server-5.7.44-1.el7.x86_64 1/4Verifying : mysql-community-client-5.7.44-1.el7.x86_64 2/4Verifying : mysql-community-libs-5.7.44-1.el7.x86_64 3/4Verifying : mysql-community-common-5.7.44-1.el7.x86_64 4/4Installed:mysql-community-server.x86_64 0:5.7.44-1.el7Dependency Installed:mysql-community-client.x86_64 0:5.7.44-1.el7 mysql-community-common.x86_64 0:5.7.44-1.el7 mysql-community-libs.x86_64 0:5.7.44-1.el7Complete!
这回版本对了:
$ mysql --version
mysql Ver 14.14 Distrib 5.7.44, for Linux (x86_64) using EditLine wrapper
启动MySQL:
$ sudo service mysqld start
Redirecting to /bin/systemctl start mysqld.service$ sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since Fri 2024-07-26 09:09:16 GMT; 2s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 15192 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 15265 (mysqld)Status: "Server is operational"Tasks: 38Memory: 453.6MCGroup: /system.slice/mysqld.service└─15265 /usr/sbin/mysqldJul 26 09:09:09 instance-20240726-1658-mysql5-7 systemd[1]: Starting MySQL Server...
Jul 26 09:09:16 instance-20240726-1658-mysql5-7 systemd[1]: Started MySQL Server.
查看监听端口:
$ netstat -a|grep -i mysql
tcp6 0 0 [::]:mysql [::]:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 57530 /var/lib/mysql/mysql.sock$ grep mysql /etc/services
mysql 3306/tcp # MySQL
mysql 3306/udp # MySQL
mysql-cluster 1186/tcp # MySQL Cluster Manager
mysql-cluster 1186/udp # MySQL Cluster Manager
mysql-cm-agent 1862/tcp # MySQL Cluster Manager Agent
mysql-cm-agent 1862/udp # MySQL Cluster Manager Agent
mysql-im 2273/tcp # MySQL Instance Manager
mysql-im 2273/udp # MySQL Instance Manager
mysql-proxy 6446/tcp # MySQL Proxy
mysql-proxy 6446/udp # MySQL Proxy
获取临时root口令:
$ sudo grep 'temporary password' /var/log/mysqld.log
2024-07-26T09:43:53.618877Z 1 [Note] A temporary password is generated for root@localhost: <T*jrhDpK5+k
接下来,如果希望安装示例Schema,可参考这里。
如果希望通过SQL Developer管理,可参考这里。
参考
- https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html