ARM架构下安装mysql8.0
在华为麦芒6手机上安装虚拟机,部署ubuntu系统,不是要学习Django嘛,于是默认安装了mysql5.7,今天在学习Django的过程中,发现最新版本的Django要mysql8.0以上的数据库才能支持,于是只能想办法在手机虚拟机的Ubuntu系统上装mysql8.0。
官网下载地址:https://downloads.mysql.com/archives/community/
基础设置
解压安装包: root@MyHost:~# tar xvf mysql-8.0.32-linux-glibc2.17-aarch64.tar.gz 将解压后的文件MV到/usr/local/路径下: root@MyHost:~# mv mysql-8.0.32-linux-glibc2.17-aarch64 /usr/local/ 修改文件夹名称: root@MyHost:/usr/local# mv mysql-8.0.32-linux-glibc2.17-aarch64 mysql 创建mysql用户: root@MyHost:/usr/local/mysql# useradd -s /sbin/nologin mysql 创建数据目录: root@MyHost:/usr/local/mysql# mkdir data 创建日志目录: root@MyHost:/usr/local/mysql# mkdir logs 给mysql运行目录授权: root@MyHost:/usr/local# chown mysql:mysql -R /usr/local/mysql
生成mysql配置文件
vim /etc/my.cnf [mysqld] bind-address=0.0.0.0 port=3306 user=mysql basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/tmp/mysql.sock log-error=/usr/local/mysql/logs/mysql.err pid-file=/usr/local/mysql/mysql.pid #character config character_set_server=utf8mb4 symbolic-links=0
初始化mysql
root@MyHost:~# cd /usr/local/mysql/bin/ root@MyHost:/usr/local/mysql/bin# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --initialize ./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
# 解决办法,安装numactl root@MyHost:/usr/local/mysql/bin# apt install numactl # 再次初始化 root@MyHost:/usr/local/mysql/bin# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --initialize
从mysql日志中查看登录初始密码
cat /usr/local/mysql/logs/mysql.err
2023-08-09T15:12:46.069128Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-08-09T15:12:47.608261Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-08-09T15:12:52.225033Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ApDyiwczq4+V
启动mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql service mysql start 启动命令执行完成之后发现端口没有监听,控制台也没有报错,只好去日志中寻找端倪。 2023-08-09T15:16:04.872500Z 0 [ERROR] [MY-010250] [Server] Failed to create a socket for IPv4 '0.0.0.0': errno: 13. 2023-08-09T15:16:04.872539Z 0 [ERROR] [MY-010255] [Server] Can't create IP socket: Permission denied 2023-08-09T15:16:04.872571Z 0 [ERROR] [MY-010119] [Server] Aborting 出现这个问题的原因: 由于我的Ubuntu是运行在安卓虚拟机上,因此Android 内核已使用 CONFIG_ANDROID_PARANOID_NETWORK 进行编译。需要通过将 mysql 用户添加到 aid_inet 和 aid_net_raw 组来修复它。原始链接:https://www.coder.work/article/516580
root@MyHost:~# usermod -a -G aid_inet,aid_net_raw mysql root@MyHost:~# service mysql start Starting MySQL .. * root@MyHost:~# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:3306 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 70 *:33060 *:* LISTEN 0 128 *:22
使用初始密码登录
root@MyHost:~# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32
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>
mysql> alter user user() identified by '123.com';
Query OK, 0 rows affected (0.05 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.32 |
+-----------+
1 row in set (0.00 sec)
mysql>
大功告成,可以继续让闲置手机发挥余热了。