Centos7-mysql-8.0.24-rpm(aarch)编译安装
what:Centos7-mysql-8.0.24-rpm(aarch)
where: centos 7.9
1.环境信息
(1)查看docker版本
[root@ecs-hk-arm ~]# docker -v
Docker version 20.10.2, build 2291f61
(2)为保证环境纯净,以镜像centos7启动docker容器
[root@ecs-hk-arm ~]# docker run -itd --name centos7-mysql8.0.24 centos:7
17ae095ca2bcf6a8fcfded7c69dc170b142bdac055731b7b192925120732907f
[root@ecs-hk-arm ~]# docker exec -it centos7-mysql8.0.24 bash
(3)查看操作系统及内核版本
[root@17ae095ca2bc /]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (AltArch)
[root@17ae095ca2bc /]# uname -a
Linux 17ae095ca2bc 4.18.0-193.28.1.el7.aarch64 #1 SMP Wed Oct 21 16:25:35 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
2.安装依赖
[root@17ae095ca2bc /]# yum install -y epel-release
[root@17ae095ca2bc /]# yum install -y rpm-build make openldap-devel cyrus-sasl-devel openssl-devel numactl-devel ncurses-devel libaio-devel zlib-devel bison time perl perl-devel autoconf libaio perl-JSON.noarch perl-Env.noarch cmake3
3.gcc10.2.1安装(centos7默认版本是4.8.5)
[root@17ae095ca2bc installed]# yum install centos-release-scl -y
[root@17ae095ca2bc installed]# yum install devtoolset-10 -y ##devtoolset-10对应gcc10.x.x版本
[root@17ae095ca2bc installed]# source /opt/rh/devtoolset-10/enable
[root@17ae095ca2bc installed]# gcc --version ##查看版本是gcc10.2.1
gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@17ae095ca2bc installed]# g++ --version ##查看版本是g++10.2.1
g++ (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5.编译安装
(1)获取源码
[root@17ae095ca2bc installed]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-8.0.24-1.el7.src.rpm
[root@17ae095ca2bc installed]# ll
total 410264
-rw-r--r-- 1 root root 420103544 Mar 23 11:53 mysql-community-8.0.24-1.el7.src.rpm
(2)编译
[root@17ae095ca2bc installed]# rpm -ivh mysql-community-8.0.24-1.el7.src.rpm
[root@17ae095ca2bc installed]# rpmbuild -ba /root/rpmbuild/SPECS/mysql.spec
Wrote: /root/rpmbuild/SRPMS/mysql-community-8.0.24-1.el7.src.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-server-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-client-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-common-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-test-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-devel-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-libs-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-client-plugins-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-libs-compat-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-community-embedded-compat-8.0.24-1.el7.aarch64.rpm
Wrote: /root/rpmbuild/RPMS/aarch64/mysql-router-community-8.0.24-1.el7.aarch64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.j3ACNw
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd mysql-8.0.24
+ /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/mysql-community-8.0.24-1.el7.aarch64
+ exit 0
(3)配置yum本地仓库安装mysql包
#安装createrepo
[root@17ae095ca2bc aarch64]# yum install createrepo -y
#将存放安装包的目录制作成软件仓库,命令执行成功后会在该目录下创建一个repodata目录
[root@17ae095ca2bc aarch64]# createrepo /root/rpmbuild/RPMS/aarch64
Spawning worker 0 with 2 pkgs
Spawning worker 1 with 2 pkgs
Spawning worker 2 with 1 pkgs
Spawning worker 3 with 1 pkgs
Spawning worker 4 with 1 pkgs
Spawning worker 5 with 1 pkgs
Spawning worker 6 with 1 pkgs
Spawning worker 7 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
#创建.repo配置文件指向到本地仓库的路径,注意文件名一定要是.repo结尾
[root@17ae095ca2bc installed]# cat /etc/yum.repos.d/test.repo
[test]
name=test
baseurl=file:///root/rpmbuild/RPMS/aarch64
enabled=1
gpgcheck=0
#通过yum repolist命令查看本地test仓库
[root@17ae095ca2bc installed]# yum repolist
[root@17ae095ca2bc installed]# yum clean all
[root@17ae095ca2bc installed]# yum makecache
[root@17ae095ca2bc installed]# yum list |grep 8.0.24
[root@17ae095ca2bc aarch64]# yum list |grep 8.0.24
mysql-community-client.aarch64 8.0.24-1.el7 test
mysql-community-client-plugins.aarch64 8.0.24-1.el7 test
mysql-community-common.aarch64 8.0.24-1.el7 test
mysql-community-devel.aarch64 8.0.24-1.el7 test
mysql-community-embedded-compat.aarch64 8.0.24-1.el7 test
mysql-community-libs.aarch64 8.0.24-1.el7 test
mysql-community-libs-compat.aarch64 8.0.24-1.el7 test
mysql-community-server.aarch64 8.0.24-1.el7 test
mysql-community-test.aarch64 8.0.24-1.el7 test
mysql-router-community.aarch64 8.0.24-1.el7 test
[root@17ae095ca2bc installed]# yum install -y mysql-community-server.aarch64
[root@17ae095ca2bc installed]# yum install -y mysql-community-client.aarch64
6.数据库配置验证
参考官方文档:https://dev.mysql.com/doc/refman/5.7/en/postinstallation.html
(1)初始化数据库,初始化时不产生临时密码,使用空密码登录,参考如下链接:
https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization.html
[root@17ae095ca2bc sbin]# cd /usr/sbin/
[root@17ae095ca2bc sbin]# ./mysqld --user=mysql --initialize-insecure
[root@17ae095ca2bc sbin]# cat /var/log/mysqld.log
2021-09-02T11:30:24.724208Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.24) initializing of server in progress as process 75348
2021-09-02T11:30:24.731051Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-09-02T11:30:25.208398Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-09-02T11:30:27.047908Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
(2)mysql启动完成后登录数据库修改初始密码重新登陆
[root@17ae095ca2bc sbin]# ./mysqld --user=mysql &
[1] 75392
[root@17ae095ca2bc sbin]# ps -ef|grep mysql
mysql 75392 15 5 11:31 pts/1 00:00:00 ./mysqld --user=mysql
root 75436 15 0 11:31 pts/1 00:00:00 grep --color=auto mysql
[root@17ae095ca2bc sbin]# mysql -V
mysql Ver 8.0.24 for Linux on aarch64 (MySQL Community Server - GPL)
[root@17ae095ca2bc sbin]# mysql -V
mysql Ver 8.0.24 for Linux on aarch64 (MySQL Community Server - GPL)
[root@17ae095ca2bc sbin]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.24 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>
(3)新建数据库新建简单数据表查看数据
mysql> create database test;
Query OK, 1 row affected (0.01 sec)
mysql> use test ;
Database changed
mysql> create table test1 (id int not null primary key,name varchar(10));
Query OK, 0 rows affected (0.03 sec)
mysql> insert into test1(id,name) values (1,'Tom'),(2,'Mary');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from test1;
+----+------+
| id | name |
+----+------+
| 1 | Tom |
| 2 | Mary |
+----+------+
2 rows in set (0.00 sec)
(4)更新数据、删除数据
mysql> update test1 set name='linda' where id=1;use test ;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Database changed
mysql> select * from test1;
+----+-------+
| id | name |
+----+-------+
| 1 | linda |
| 2 | Mary |
+----+-------+
2 rows in set (0.00 sec)
mysql> delete from test1 where id=1;
Query OK, 1 row affected (0.00 sec)
mysql> select * from test1;
+----+------+
| id | name |
+----+------+
| 2 | Mary |
+----+------+
1 row in set (0.00 sec)