Enable the remote access of MariaDB in Synology NAS

Among the third-party packages supported on Synology NAS, there is an open source database system MariaDB that can be installed and used, but after the installation is complete, the default is remote that cannot be accessed remotely. This article simply records how to configure remote access in the local area network.

Configure NAS SSH service

Select “Control Pannel” in the web management interface of the NAS, find the “Terminal & SNMP” icon at the bottom and click, and check “Enable SSH service” on the next screen.

Configure MariaDB

Log in to the NAS remotely via SSH and find the Mariadb installation directory. The default should be /usr/local/mariadb10 (MariaDB 10 is installed). Enter the bin directory:

1
cd /usr/local/mariadb10/bin

You will see the client application-mysql in this directory. Execute mysql to start the client:

1
./mysql -u root -p

Enter the root password set on the web management interface of the NAS. After the login is successful, the system displays the MariaDB prompt, similar to the following:

1
2
3
4
5
6
7
8
9
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
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)]>

Execute the following SQL statement to add a root account that can be accessed remotely.

1
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.%' IDENTIFIED BY '<your password>' WITH GRANT OPTION;

Replace “192.168.1.%” with your IP, and set the password to your password.

After execution, you can use the following SQL statement to view the results

1
SELECT User, Host FROM mysql.user WHERE Host <> 'localhost';

The query results are similar to the following:

1
2
3
4
5
6
7
8
+------+-------------+
| User | Host |
+------+-------------+
| root | 127.0.0.1 |
| root | 192.168.1.% |
| root | ::1 |
+------+-------------+
3 rows in set (0.001 sec)

As you can see, the new root user has been added to the MariaDB system. Next, you can use a computer in the 192.168.1.% network segment to log in to the database.

More About Synology NAS

How to setup Git Server on Synology NAS How to Config the basic authentication for Web Station of Synology NAS

本文标题:Enable the remote access of MariaDB in Synology NAS

文章作者:Morning Star

发布时间:2021年07月12日 - 12:07

最后更新:2022年01月28日 - 11:01

原始链接:https://www.mls-tech.info/linux/nas-enable-mariadb-remote-access_en/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。