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'

参考:
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;

【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

【参考】

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)

(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

Ⅱ、注释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

(3)参考

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

你可能感兴趣的:(数据库-MySQL,mysql,openEuler,arm)