Wood Chen

Enable Remote Access to MariaDB on Synology NAS

0 comments279 views232 words

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)

  1. Add new host permissions for the root user: If you want to keep the existing root@localhost user and allow root to connect from the 10.%%.%%.%% 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_password with the password you want to use.

  2. Change the host for the existing root user: If you want root to connect from the 10.%%.%%.%% network instead of localhost, 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

Related posts

Comments 0