银河麒麟V10(ARM) 离线安装 MySQL
参考教程:
https://www.cnblogs.com/liuweida/p/17105179.html
https://www.cnblogs.com/wshisboy/p/16374015.html
1. MySQL 8.0.29版本下载
直接官网下载:
https://dev.mysql.com/downloads/mysql/
选择版本:
2. 安装MySQL
2.1 删除原有的mariadb
先查看一下是否已经安装了
rpm -qa | grep mysql
rpm -qa | grep mariadbrpm -e --nodeps mariadb-libs
rpm -e mariadb-server --nodeps
yum -y remove mysql*
yum -y remove mariadb*
删除mariadb
,命令:
rpm -e --nodeps mariadb-libs
rpm -e mariadb-server --nodeps
2.2 解压缩mysql离线安装包
[root@localhost MYSQL安装包]# tar xvf mysql-8.1.0-1.el8.aarch64.rpm-bundle.tar
逐个安装,命令如下:
必须安装
[root@localhost MYSQL安装包]# rpm -ivh mysql-community-common-8.1.0-1.el8.aarch64.rpm
[root@localhost MYSQL安装包]# rpm -ivh mysql-community-client-plugins-8.1.0-1.el8.aarch64.rpm
[root@localhost MYSQL安装包]# rpm -ivh mysql-community-libs-8.1.0-1.el8.aarch64.rpm
[root@localhost MYSQL安装包]# rpm -ivh mysql-community-client-8.1.0-1.el8.aarch64.rpm
[root@localhost MYSQL安装包]# rpm -ivh mysql-community-icu-data-files-8.1.0-1.el8.aarch64.rpm
[root@localhost MYSQL安装包]# rpm -ivh mysql-community-server-8.1.0-1.el8.aarch64.rpm
[root@localhost MYSQL安装包]# rpm -ivh mysql-community-devel-8.1.0-1.el8.aarch64.rpm
查看mysql
[root@localhost MYSQL安装包]# rpm -qa |grep mysql
mysql-community-client-8.1.0-1.el8.aarch64
mysql-community-server-8.1.0-1.el8.aarch64
mysql-community-client-plugins-8.1.0-1.el8.aarch64
mysql-community-icu-data-files-8.1.0-1.el8.aarch64
mysql-community-common-8.1.0-1.el8.aarch64
mysql-community-devel-8.1.0-1.el8.aarch64
mysql-community-libs-8.1.0-1.el8.aarch64
3. 初始化mysql服务
3.1 查看服务状态
命令:
[root@localhost MYSQL安装包]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pres>
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
接下来要启动MySQL
,通过执行以下命令启动:
[root@localhost MYSQL安装包]# systemctl start mysqld
启动过程并不会返回任何信息即为成功。
再次查询状态
[root@localhost MYSQL安装包]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pres>
Active: active (running) since Mon 2023-07-31 14:52:26 CST; 11s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 9165 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0>
Main PID: 9242 (mysqld)
Status: "Server is operational"
Tasks: 38
Memory: 596.7M
CGroup: /system.slice/mysqld.service
└─9242 /usr/sbin/mysqld
激活状态Active
显示为active
,则表示启动成功。
3.2 配置MySQL
MySQL
安装完成后需要对MySQL
做基础配置,包括首次登录修改用户密码、数据文件位置调整、redo log
大小与数量调整、undo
表空间调整、ibdata
表空间调整、binlog+errorlog+slowlog+pid+socket
等文件调整、性能参数调整,这些调整都可以通过修改my.cnf
参数文件实现。
在MySQL
安装完成第一次启动MySQL
服务后,会自动为MySQL
的root
用户生成一个随机初始化密码,并在MySQL
的errorlog
文件中记录下来,我们要找到它并用它登录MySQL
,修改root
用户密码后才能执行任何其它操作:
- 找到初始化密码
[root@localhost MYSQL安装包]# grep password /var/log/mysqld.log
2023-07-31T06:52:18.907755Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #SL7tAyY5ih)
#SL7tAyY5ih)即为初始化密码,注意是冒号后面的所有字符都是密码
- 使用上面的初始化密码登录MySQL
[root@localhost MYSQL安装包]# mysql -uroot -p
- 修改root密码
使用初始化密码登录MySQL
后只能执行修改密码的操作,其他任何操作都是不可能的,使用以下命令修改密码:
mysql> alter user user() identified by 'LaoGeDB123!';
Query OK, 0 rows affected (0.02 sec)
密码修改成功后,执行以下命令查看MySQL
基本信息:
mysql> status
--------------
mysql Ver 8.1.0 for Linux on aarch64 (MySQL Community Server - GPL)
Connection id: 12
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.1.0
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /var/lib/mysql/mysql.sock
Binary data as: Hexadecimal
Uptime: 25 min 43 sec
Threads: 2 Questions: 10 Slow queries: 0 Opens: 130 Flush tables: 3 Open tables: 46 Queries per second avg: 0.006
--------------
- 授权远程连接
查看当前权限
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> use mysql;
mysql> select host,user,plugin from user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)
授权远程访问
mysql> update user set host="%" where user='root';
mysql> select host,user,plugin from user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| % | root | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)