使用 ssh 登录到群晖
进入 MariaDB 默认安装目录
MariaDB5:
cd /volume1/@appstore/MariaDB/usr/bin
MariaDB10:
cd /volume1/@appstore/MariaDB10/usr/local/mariadb10/bin
使用 root 登录 MariaDB,然后进行修改
./mysql -u root -p
use mysql
select host,user from user;
update user set host = '%' where user = 'root';
select host,user from user;
FLUSH PRIVILEGES;
其中 host 为 % 表示不限制IP,你也可以设置具体的IP地址,或者网段 192.168.1.% 这样。另外,上面出现的 ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 不予理会,其意思是 host 为主键,不能设置重复的值。所以我们后来的查询中,host 还是3个不同的值。刚刚执行的 update 语句只成功修改了数据库中一条数据。
MariaDB5:
xxxx@xxxx:/$ cd /volume1/@appstore/MariaDB/usr/bin
xxxx@xxxx:/volume1/@appstore/MariaDB/usr/bin$ ./mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 250
Server version: 5.5.62-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)]> use mysql
Database changed
MariaDB [mysql]> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
MariaDB [mysql]> update user set host = '%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
MariaDB [mysql]> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
+-----------+------+
3 rows in set (0.00 sec)
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]>
MariaDB10:
xxxx@xxxx:/$ cd /volume1/@appstore/MariaDB10/usr/local/mariadb10/bin
xxxx@xxxx:/volume1/@appstore/MariaDB10/usr/local/mariadb10/bin$ ./mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.21-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)]> use mysql
Database changed
MariaDB [mysql]> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.000 sec)
MariaDB [mysql]> update user set host = '%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
MariaDB [mysql]> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
+-----------+------+
3 rows in set (0.000 sec)
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [mysql]>
