稷然如此

  • 首页
  • 文章分类
    • AI
    • Android
    • Java
    • Shell
    • Vue
    • C#
    • Python
    • 数据库
    • 组件
    • 其他
    • Game
  • 常用命令
    • Docker
    • Git
    • Linux
  • 操作系统
    • CentOS
    • Ubuntu
    • Windows
    • Kylin
    • Euler
  • 工具
    • IntelliJ IDEA
    • Visual Studio Code
稷然如此
不积跬步,无以至千里
  1. 首页
  2. 操作系统
  3. Euler
  4. 正文

Open Euler 24 安装 mysql 8.0+

2026年3月20日 12点热度 0人点赞

1.下载

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.37-linux-glibc2.28-x86_64.tar.xz

2.解压

# 解压
tar -xvf mysql-8.0.37-linux-glibc2.28-x86_64.tar.xz

# 移动到指定目录
mv mysql-8.0.37-linux-glibc2.28-x86_64 /opt/mysql

3.创建用户

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

4.创建数据目录

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

# 创建日志文件
touch /opt/mysql/error.log

# 修改权限
chown mysql:mysql /opt/mysql/error.log

# 确保目录权限也对
chown -R mysql:mysql /opt/mysql

5.初始化数据库

/opt/mysql/bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data
执行后会输出:
# 需要记住这个输出的密码
A temporary password is generated for root@localhost: xxxx

6.配置 my.cnf

vim /etc/my.cnf

# 写入:
[client]
socket=/opt/mysql/mysql.sock

[mysqld]
basedir=/opt/mysql
datadir=/opt/mysql/data
socket=/opt/mysql/mysql.sock
pid-file=/opt/mysql/mysqld.pid

port=3306
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci

# 关闭DNS解析(强烈建议)
skip-name-resolve

# 日志
log-error=/opt/mysql/error.log

7.启动 MySQL

启动后,新建或复制会话,在新窗口继续第 8 步一下操作
/opt/mysql/bin/mysqld_safe --user=mysql &

8.登录 MySQL

/opt/mysql/bin/mysql -uroot -p
# 输入刚才记下来的临时密码

9.修改 root 密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@123456';

10.设置允许远程连接

CREATE USER 'root'@'%' IDENTIFIED BY 'Root@123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

11.设置开机启动

cp /opt/mysql/support-files/mysql.server /etc/init.d/mysql

chkconfig --add mysql

chkconfig mysql on service mysql restart

service mysql status

 

标签: MySql open euler
最后更新:2026年3月20日

Akim

犇 骉 Java、C#、Python、Go、Android、MiniProgram、Bootstrap、Vue2

点赞
< 上一篇
文章目录
  • 1.下载
  • 2.解压
  • 3.创建用户
  • 4.创建数据目录
  • 5.初始化数据库
  • 6.配置 my.cnf
  • 7.启动 MySQL
  • 8.登录 MySQL
  • 9.修改 root 密码
  • 10.设置允许远程连接
  • 11.设置开机启动

Copyright © 2025 aianran.com All Rights Reserved.

免责申明 | 隐私政策 | 服务条款 | 关于我们

黔ICP备2023008200号-1

贵公网安备 52010202003594号