莱因电博

Li-e.cn

Li Internet Electronic Blog
@rss

在通用ARM Linux 上安装 MySQL8 数据库

How to install MySQL8 database on Generic ARM Linux?

————————————————————

因为官方给的 rpm 包安装不了啊,需要手动安装了。

1. 下载 MySQL8

下载地址:downloads.mysql.com

The first step is to prepare an Oracle account and download it here: downloads.mysql.com

本文以 mysql-8.0.35 为例,文件:mysql-8.0.35-linux-glibc2.17-aarch64.tar.xz

2. 安装步骤

2.1 设置安装目录

mkdir -p /opt
tar -xvf mysql-8.0.35-linux-glibc2.17-aarch64.tar.xz -C /opt
mv /opt/mysql-8.0.35-linux-glibc2.17-aarch64 /opt/mysql-8.0.35

2.2 设置MySQL用户

groupadd mysql
useradd -r -g mysql mysql

2.3 设置数据储存路径

mkdir -p  /data/mysql
chown mysql:mysql -R /data/mysql

2.4 新建配置MySQL文件

vi /etc/mysql.cnf

编辑内容:

[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql

basedir=/opt/mysql-8.0.35
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid

#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true

2.5 初始化MySQL配置

cd /opt/mysql-8.0.35/bin
./mysqld --defaults-file=/etc/mysql.cnf --basedir=/opt/mysql-8.0.35/ --datadir=/data/mysql/ --user=mysql --initialize

2.6 查看初始密码

cat /data/mysql/mysql.err

Then, you can see something like this:

etek@ls1046ardb:/opt/mysql-8.0.35/bin# cat /data/mysql/mysql.err
2024-02-21T08:29:39.043983Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2024-02-21T08:29:39.057022Z 0 [System] [MY-013169] [Server] /opt/mysql-8.0.35/bin/mysqld (mysqld 8.0.35) initializing of server in progress as process 1025
2024-02-21T08:29:39.342060Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-02-21T08:29:44.721887Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-02-21T08:29:58.805123Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: vdtYSM=/a5ef
etek@ls1046ardb:/opt/mysql-8.0.35/bin#

The character “vdtYSM=/a5ef” is your initial password.

2.6 设置并启动MySQL服务

cp ../support-files/mysql.server /etc/init.d/mysql
service mysql start

And then, you can see something like this:

etek@ls1046ardb:/opt/mysql-8.0.35/bin# service mysql start
Starting MySQL... SUCCESS!
etek@ls1046ardb:/opt/mysql-8.0.35/bin#

Congratulations, successful startup!

到此,MySQL安装结束。

3. 修改MySQL密码

./mysql -u root -p

进入 MySQL 命令行:

etek@ls1046ardb:/opt/mysql-8.0.35/bin# ./mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35

Copyright (c) 2000, 2023, 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>

以修改密码为 “123456” 为例:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;

4. 配置 MySQL 远程连接

PS: For “root”

use mysql;
update user set host='%' where user='root';
flush privileges;

5. 退出 MySQL 命令行

exit;

6. 将 MySQL 命令生效到 系统终端

即:可以在 任意目录 使用 mysql 命令

export PATH=$PATH:/opt/mysql-8.0.35/bin

教程结束,放心食用。

(C) 2019 - 2024 Li-e.cn莱因电博(立网电子博客) | Powered by Vercel , based on Hugo with Gists theme.