CentOS7安装Mysql5.7(鲲鹏服务器aarch64)

1. 前置工作

[root@les bin]# cd /home
[root@les home]# wget https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/database/patch/rpm-bug.zip
[root@les home]#
[root@les home]# unzip rpm-bug.zip
[root@les home]# cd rpm-bug
[root@les rpm-bug]# cp libatomic.so.1 /usr/lib64/
cp: overwrite ‘/usr/lib64/libatomic.so.1’? y
[root@les rpm-bug]# cp libstdc++.so.6.0.24 /lib64/
cp: overwrite ‘/lib64/libstdc++.so.6.0.24’? y
[root@les rpm-bug]# rm /lib64/libstdc++.so.6
rm: remove symbolic link ‘/lib64/libstdc++.so.6’? y
[root@les rpm-bug]# ln -s /lib64/libstdc++.so.6.0.24 /lib64/libstdc++.so.6
[root@les rpm-bug]# cp libaio.so.1.0.1 /usr/lib64/libaio.so.1

2.配置本地yum源

[root@les ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d-bak
[root@les ~]# ls /etc/yum.repos.d-bak/*
/etc/yum.repos.d-bak/CentOS-Base.repo

/etc/yum.repos.d-bak/repo_bak:
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo  epel.repo  epel-testing.repo
[root@les ~]# echo -e "[kunpeng]\nname=CentOS-kunpeng - Base - mirrors.huaweicloud.com\nbaseurl=https://mirrors.huaweicloud.com/kunpeng/yum/el/7/aarch64/\ngpgcheck=0\nenabled=1" > /etc/yum.repos.d/CentOS-Base-kunpeng.repo

3.安装rpm

3.1 清除缓存
[root@les ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras kunpeng updates
Cleaning up list of fastest mirrors
Other repos take up 155 M of disk space (use --verbose for details)
3.2 刷新缓存
[root@les ~]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
base    | 3.6 kB  00:00:00
extras  | 2.9 kB  00:00:00
kunpeng | 2.9 kB  00:00:00
updates | 2.9 kB  00:00:00
(1/13): base/7/aarch64/group_gz            | 153 kB  00:00:00
(2/13): base/7/aarch64/filelists_db        | 6.2 MB  00:00:00
(3/13): base/7/aarch64/other_db            | 2.1 MB  00:00:00
(4/13): extras/7/aarch64/primary_db        | 240 kB  00:00:00
(5/13): extras/7/aarch64/filelists_db      | 286 kB  00:00:00
(6/13): extras/7/aarch64/other_db          | 142 kB  00:00:00
(7/13): base/7/aarch64/primary_db          | 4.9 MB  00:00:00
(8/13): kunpeng/primary_db                 |  90 kB  00:00:00
(9/13): kunpeng/other_db                   | 8.5 kB  00:00:00
(10/13): updates/7/aarch64/filelists_db    | 1.6 MB  00:00:00
(11/13): kunpeng/filelists_db              | 778 kB  00:00:00
(12/13): updates/7/aarch64/other_db        | 427 kB  00:00:00
(13/13): updates/7/aarch64/primary_db      | 1.1 MB  00:00:00
Metadata Cache Created

3.3  安装文件

yum -y install mysql-5.7.27-1.el7.aarch64 --enablerepo=[kunpeng]

4. 验证安装

[root@les ~]# rpm -qa | grep mysql
mysql-5.7.27-1.el7.aarch64

5. 修改配置文件

[root@les mysql]# echo -e "[mysqld_safe]\nlog-error=/data/mysql/log/mysql.log\npid-file=/data/mysql/run/mysqld.pid\n[mysqldump]\nquick\n[mysql]\nno-auto-rehash\n[client]\ndefault-character-set=utf8\nsocket=/data/mysql/run/mysql.sock\n[mysqld]\nbasedir=/usr/local/mysql\ntmpdir=/data/mysql/tmp\ndatadir=/data/mysql/data\ndefault_authentication_plugin=mysql_native_password\nport=3306\nuser=mysql\n" > /etc/my.cnf
[root@les mysql]#
[root@les mysql]# cat /etc/my.cnf
[mysqld_safe]
log-error=/data/mysql/log/mysql.log
pid-file=/data/mysql/run/mysqld.pid
[mysqldump]
quick
[mysql]
no-auto-rehash
[client]
default-character-set=utf8
socket=/data/mysql/run/mysql.sock
[mysqld]
basedir=/usr/local/mysql
tmpdir=/data/mysql/tmp
datadir=/data/mysql/data
default_authentication_plugin=mysql_native_password
port=3306
user=mysql

设置配置文件权限

[root@les mysql]# chown mysql:mysql /etc/my.cnf

6. 创建数据目录

[root@les mysql]# mkdir -p /data/mysql/log /data/mysql/tmp /data/mysql/data /data/mysql/run
[root@les mysql]#
[root@les mysql]# ls /data/mysql
data  log  run  tmp

[root@les home]# chown mysql:mysql /data/mysql/log /data/mysql/tmp /data/mysql/data /data/mysql/run /data/mysql
[root@les home]# ls -lrt /data
total 4
drwxr-xr-x 6 mysql mysql 4096 May 29 10:06 mysql

7.配置环境变量

[root@les mysql]# echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile
[root@les mysql]# source /etc/profile

8. 初始化及启动数据库

[root@les ~]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --basedir=/usr/local/mysql --datadir=/data/mysql/data
2021-05-29T03:05:41.127798Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-29T03:05:41.296027Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-29T03:05:41.335403Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-29T03:05:41.348709Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c05e259d-c02a-11eb-be77-fa163eec4f47.
2021-05-29T03:05:41.351537Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-29T03:05:41.352305Z 1 [Note] A temporary password is generated for root@localhost: BThyTjwh(2BR
[root@les ~]# su  mysql
Last login: Sat May 29 11:12:02 CST 2021 on pts/1
-bash-4.2$
-bash-4.2$ /usr/local/mysql/bin/mysqld_safe --user=root --basedir=/usr/local/mysql --datadir=/data/mysql/data &
[1] 13100
-bash-4.2$ 2021-05-29T03:15:52.313343Z mysqld_safe Logging to '/data/mysql/log/mysql.log'.
2021-05-29T03:15:52.331984Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data
-bash-4.2$ ps -ef | grep mysql
mysql    13100 13077  0 11:15 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=root --basedir=/usr/local/mysql --datadir=/data/mysql/data
mysql    13307 13100  0 11:15 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysql/log/mysql.log --pid-file=/data/mysql/run/mysqld.pid --port=3306
-bash-4.2$

9.配置数据库

输入初始化数据库时的密码:BThyTjwh(2BR

-bash-4.2$ /usr/local/mysql/bin/mysql -uroot -p -S /tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'root'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit

你可能感兴趣的:(运维部署,mysql,centos,运维,数据库)