群晖7.2 安装了mariadb,如何开启外网访问权限

文章描述了在群晖7.2上安装并配置MariaDB时,遇到ERROR1356错误,如何正确更新root用户权限以实现外网访问的详细步骤。作者提供了正确操作顺序,包括安装MariaDB、开启SSH、设置权限等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

群晖7.2 安装了mariadb,如何开启外网访问权限遇到的问题,及解决办法记录。

前言

群晖7.2 安装了mariadb,想要开启外网访问权限,网站找了很多教程,都比较老了,有的已经不适用了,
这里将遇到**ERROR 1356 (HY000)**报错的解决做一下记录:
MariaDB [mysql]> update user set host=‘%’ where user=‘root’;
ERROR 1356 (HY000): View ‘mysql.user’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

操作过程及报错

下面是网上教程的大致操作过程(会报错)

  1. 首先,确保您的群晖NAS(Network Attached Storage,网络附加存储)已经安装了MariaDB数据库。您可以从套件中心(Package Center)中搜索并安装MariaDB套件。
  2. 安装完成后,打开SSH功能。在套件中心中搜索“shell”并安装“Shell & File Access”套件。然后,在Shell & File Access设置中启用SSH功能,并设置好SSH端口号。
  3. 使用SSH客户端(如PuTTY)连接到群晖NAS的IP地址和设置的SSH端口号。输入群晖的登录用户名和密码,登录到群晖的命令行界面。
  4. 进入MariaDB的安装目录。默认情况下,MariaDB安装在“/volume1/@appstore/MariaDB10/usr/local/mariadb10/bin”目录下。您可以使用以下命令进入该目录:
cd /volume1/@appstore/MariaDB10/usr/local/mariadb10/bin
  1. 登录到MariaDB数据库。使用以下命令以root用户身份登录:
./mysql -u root -p
  1. 在MariaDB提示符下,执行以下命令来更新root用户的访问权限:
use mysql;
update user set host='%' where user='root';

到这里报错
MariaDB [mysql]> update user set host=‘%’ where user=‘root’;
ERROR 1356 (HY000): View ‘mysql.user’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

正确操作按以下步骤进行操作:

  1. 首先,确保您的群晖NAS(Network Attached Storage,网络附加存储)已经安装了MariaDB数据库。您可以从套件中心(Package Center)中搜索并安装MariaDB套件。
  2. 安装完成后,打开SSH功能。在套件中心中搜索“shell”并安装“Shell & File Access”套件。然后,在Shell & File Access设置中启用SSH功能,并设置好SSH端口号。
  3. 使用SSH客户端(如PuTTY)连接到群晖NAS的IP地址和设置的SSH端口号。输入群晖的登录用户名和密码,登录到群晖的命令行界面。
  4. 进入MariaDB的安装目录。默认情况下,MariaDB安装在“/volume1/@appstore/MariaDB10/usr/local/mariadb10/bin”目录下。您可以使用以下命令进入该目录

用ssh连接nas后

sudo -i
# 输入群晖管理员密码
# 进入目录
cd /volume1/@appstore/MariaDB10/usr/local/mariadb10/bin

登录到MariaDB数据库。使用以下命令以root用户身份登录:

./mysql -u root -p
# 输入mariadb root 用户密码

# 'your passwd' 换成你自己的 mariadb  root密码
grant all privileges on *.* to 'root'@'%' identified by 'your passwd';
delete from mysql.user where User='';
FLUSH PRIVILEGES;

完整过程如下:

# 输入mariadb root 用户密码
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 131
Server version: 10.11.2-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> grant all privileges on *.* to 'root'@'%' identified by 'your mariadb's password';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> delete from mysql.user where User='';
Query OK, 2 rows affected (0.006 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值