• openEuler(arm架构)系统中mysql8.x安装问题解决


    安装流程参考:

    MySQL-8 在arm64-OpenEuler上的安装
    https://blog.csdn.net/zhongyoubing/article/details/126380690
    注:未经实操,不确定是否一定能行。

    一、准备工作

    1、修改密码

    mysql -u root -p
    mysql> use mysql;
    
    #  给mysql设置密码
    mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'jh2022.11'
    
    • 1
    • 2
    • 3
    • 4
    • 5

    参考:
    mysql8.0安装后设置密码
    https://blog.csdn.net/qq_35545811/article/details/127125266

    二、无法通过127.0.0.1访问

    mysql只能通过 mysql -h localhost -u root -pjh2022.11 访问;无法通过 mysql -h 127.0.0.1 -u root -pjh2022.11 访问。

    首先想到的是开放远程访问权限,但是并没有解决问题。再次通过分析查看,发现3306端口没有监听,再次解决3306端口的监听问题。

    1、开放远程访问权限

    #mysql> grant all privileges on *.* to 'root'@'127.0.0.1' identified by 'jh2022.11';
    #mysql> grant all privileges on *.* to 'root'@'%' identified by 'jh2022.11' with grant option;
    
    mysql> update user set host = '%' where user = 'root';
    mysql> create user root@'%' identified by 'jh2022.11';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
    mysql> flush privileges;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    【grant命令错误】

    The MySQL server is running with the --skip-grant-tables option so it cannot execute this st

    解决方法:

    # 刷新一下权限表
    mysql> flush privileges;
    
    # 参考:https://blog.csdn.net/qq_45839663/article/details/127236215
    
    • 1
    • 2
    • 3
    • 4

    【参考】

    MySQL 8.x 设置允许远程访问
    https://blog.csdn.net/qq_40943000/article/details/120028791

    2、解决3306端口无监听

    (1)问题展示

    无法使用 127.0.0.1 登录数据库。

    # 重启报错
    [root@lb config]# systemctl restart mysql
    Warning: The unit file, source configuration file or drop-ins of mysql.service changed on disk. Run 'systemctl daemon-reload' to reload units.
    
    # 使用localhost可以登录数据库
    [root@lb config]# mysql -h localhost -u root -pjh2022.11
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    
    # 使用127.0.0.1无法登录
    [root@lb config]# mysql -h 127.0.0.1 -u root -pjh2022.11
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    (2)问题解决步骤

    经网上查询可能原因:

    1. 关闭selinux
    2. my.cnf文件中设置了bind-address ,可以将其注释掉,或者设置 bind-address=0.0.0.0
    3. my.cnf里配置了skip_networking,只允许本地socket连接,需要将其注释掉。但是在 mysql8.x 后的版本, my.cnf 中的配置变为 skip-grant-tables,需要将其注释掉。
    Ⅰ、关闭selinux
    # 检查selinux是否关闭(disabled表明已经关闭)
    [root@lb config]# /usr/sbin/sestatus -v
    SELinux status:                 disabled
    
    • 1
    • 2
    • 3
    Ⅱ、注释bind-address

    经检查 my.cnf 中没有bind-address
    即使加入 bind-address=0.0.0.0 或者 bind-address=127.0.0.1 ,依然不能使用127.0.0.1 访问数据库。

    Ⅲ、注释skip-grant-tables
    # 检查mysql监听,没有3306端口监听
    [root@lb config]# sudo netstat -lnp |grep mysql
    unix  2      [ ACC ]     STREAM     LISTENING     169407   12158/mysqld         /tmp/mysql.sock
    unix  2      [ ACC ]     STREAM     LISTENING     168425   12158/mysqld         /tmp/mysqlx.sock
    
    # 查看3306端口
    [root@lb config]# netstat -anplt | grep 3306
    
    # 安装telnet
    [root@lb config]# yum -y install telnet-server
    
    # 测试下,果然不通
    [root@lb config]# telnet 127.0.0.1 3306
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    
    
    # 修改
    [root@lb config]# vim /etc/my.cnf
    
    
    [root@lb config]# service mysql restart
    Shutting down MySQL. SUCCESS!
    Starting MySQL. SUCCESS!
    
    # 重新查看3306端口
    [root@lb config]# netstat -an|grep 3306
    tcp6       0      0 :::33060                :::*                    LISTEN
    tcp6       0      0 :::3306                 :::*                    LISTEN
    
    # 使用127.0.0.1登录成功
    [root@lb config]# mysql -h 127.0.0.1 -u root -pjh2022.11
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35

    (3)参考

    mysql无法看到3306端口监听
    https://blog.csdn.net/shumeigang/article/details/103902459

  • 相关阅读:
    vs code 添加vue3代码模板方法
    Vitis HLS 学习笔记--HLS入门示例集合-目录
    Competition Among Parallel Contests(博弈论+机制设计) 论文阅读笔记
    PHP:纤程
    代码随想录算法训练营第23期60天完结总结
    Web优化躬行记(6)——优化闭环实践
    一篇文章带你掌握主流办公框架——SpringBoot
    【数据结构】二叉树的基本概念
    Linux环境变量配置在/etc/profile或/etc/profile.d/中有什么区别?
    【密评】商用密码应用安全性评估从业人员考核题库(一)
  • 原文地址:https://blog.csdn.net/qq_25775675/article/details/127674614