群晖NAS配置MariaDB实操教程

2023年 7月 10日 56.3k 0

群晖没有提供Mysql的安装,但是提供了MariaDB,所以直接安装MariaDB即可。

1.安装官方套件MariaDB

群晖NAS配置MariaDB实操教程

设置好端口和root密码

群晖NAS配置MariaDB实操教程

2.ssh进入服务器,创建测试数据库

默认情况下无法远程连接

群晖NAS配置MariaDB实操教程

ssh进入群晖nas服务器,直接运行mysql命令

如果运行报错,可以进入 /usr/local/mariadb10/bin这个目录下再运行,或者进入

/volume1/@appstore/MariaDB10/usr/local/mariadb10/bin 这个目录。

创建好测试用的数据库。

zhonglaonianoldjava@DS918plus:~$ mysql -uroot -p数据库root密码
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 19
Server version: 10.3.32-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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.001 sec)
MariaDB [(none)]> create database test;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [(none)]> use test;
Database changed
MariaDB [test]>

3.设置数据库权限,新建用户,并设置成可以远程访问

创建数据库中的新用户,注意密码复杂度必须要求有数字,特殊字符和大小写字母

MariaDB [test]> CREATE USER dbtestuser@'%' IDENTIFIED BY 'qqjavaold';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements: [Minimal password length 10, Include mixed case, Include numeric characters, Include special characters]
MariaDB [test]> CREATE USER dbtestuser@'%' IDENTIFIED BY 'qqjavaold&zhihu';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements: [Include mixed case, Include numeric characters]
MariaDB [test]> CREATE USER dbtestuser@'%' IDENTIFIED BY 'qqjavaold&ZH123';
Query OK, 0 rows affected (0.031 sec)
MariaDB [test]> show grants for dbtestuser;
+-----------------------------------------------------------------------------------------------------------+
| Grants for dbtestuser@%                                                                                   |
+-----------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `dbtestuser`@`%` IDENTIFIED BY PASSWORD '*xxxxx' |
+-----------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)

然后验证数据库可以远程连接了,但是还没有数据库的操作权限

群晖NAS配置MariaDB实操教程

于是给dbtestuser这个用户加上test这个数据库实例的所有权限

MariaDB [test]> grant all privileges on test.* to dbtestuser;
Query OK, 0 rows affected (0.001 sec)

MariaDB [test]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [test]> show grants for dbtestuser;
+-----------------------------------------------------------------------------------------------------------+
| Grants for dbtestuser@%                                                                                   |
+-----------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `dbtestuser`@`%` IDENTIFIED BY PASSWORD '*EAFA6F84C1B06C49EAF78DEF26C4077952FD7944' |
| GRANT ALL PRIVILEGES ON `test`.* TO `dbtestuser`@`%`                                                      |
+-----------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)


群晖NAS配置MariaDB实操教程

4.可以通过Spring+JPA自动建表进行测试了

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论