Enable Remote Access to MariaDB on Synology NAS
This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文
MariaDB, an open-source database system, is available as a third-party package on Synology NAS, but remote access is disabled by default after installation. This post briefly documents how to enable remote access on a local network.
Steps
Log in to the NAS via SSH and locate the MariaDB installation directory. The default should be /usr/local/mariadb10 (for MariaDB 10). Enter the bin directory:
cd /usr/local/mariadb10/bin
You will find the client application, mysql, in this directory. Run mysql to start the client:
./mysql -u root -p
Enter the root password you set in the NAS web admin interface. After a successful login, you will see a MariaDB prompt similar to this:
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)]>
Run the following SQL statement to check the existing users first:
SELECT User, Host FROM mysql.user;
The output will typically look like this: bash +-------------+-----------+ | User | Host | +-------------+-----------+ | PUBLIC | | | mariadb.sys | localhost | | mysql | localhost | | root | localhost | +-------------+-----------+ 4 rows in set (0.133 sec)
-
Add new host permissions for the
rootuser: If you want to keep the existingroot@localhostuser and allowrootto connect from the10.%%.%%.%%network, you can create a new user entry:CREATE USER 'root'@'10.%%.%%.%%' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.%%.%%.%%' WITH GRANT OPTION; FLUSH PRIVILEGES;Replace
your_passwordwith the password you want to use. -
Change the host for the existing
rootuser: If you wantrootto connect from the10.%%.%%.%%network instead oflocalhost, you can update the existing user's host:RENAME USER 'root'@'localhost' TO 'root'@'10.%%.%%.%%'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.%%.%%.%%' WITH GRANT OPTION; FLUSH PRIVILEGES;
You can now connect to the database as root from a 10.x.x.x host.
Last updated 2025-03-29
Comments 0