树莓派安装mariadb & redis

安装软件

sudo apt install mariadb-server mariadb-client

sudo apt install redis

二. 配置

1, mariadb 配置

配置远程访问

maridb configuration:

sudo mysql_secure_installation # 设置root密码

vim.tiny mariadb.conf.d/50-server.cnf # 设置去除本地绑定

#bind-address = 127.0.0.1

#允许root用户远程访问

mysql -u root -p

grant all privileges on . to root@"%" identified by "my_password" with grant option;

flush privileges;

重启mysql(mariadb)服务

sudo service mysql restart # 如果是mysql则为sudo service mysqld restart

使用Navicat 工具测试成功;

创建一个用户, 专门用于go_gin_api 访问 go_gin_api/go_gin_api

CREATE USER 'go_gin_api'@'%' IDENTIFIED BY 'go_gin_api'; #%代表着不限制ip

flush privileges;

root用户创建新的数据库, ps: 如果有sql 可以使用指令 mysql -u root -p < yourSQL.sql

SET @s = IF(version() < 8 OR (version() LIKE '%MariaDB%' AND version() < 10.3),

'SET GLOBAL innodb_file_per_table = ON,

innodb_file_format = Barracuda,

innodb_large_prefix = ON;',

'SET GLOBAL innodb_file_per_table = ON;');

PREPARE stmt1 FROM @s;

EXECUTE stmt1;

DROP DATABASE IF EXISTS go_gin_api;

CREATE DATABASE IF NOT EXISTS go_gin_api CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

将数据库的增删改查权限给到go_gin_api

#grant select,delete,insert,update on go_gin_api.* to go_gin_api@'%';

GRANT ALL ON go_gin_api.* TO 'go_gin_api'@'%'; # 授权:所有权限

#REVOKE ALL ON go_gin_api.* TO 'go_gin_api'@'%'; # 撤销:

flush privileges;

  1. redis 配置
    vim.tiny /etc/redis/redis.conf

开启远程访问

#bind 127.0.0.1 ::1

关闭保护模式

protected-mode no # yes->no

开启密码

requirepass my_password

使用Another Redis Desktop Manager 客户端工具打开连接成功

相关推荐
阿蒙Amon24 分钟前
C#读写文件:多种方式详解
开发语言·数据库·c#
东窗西篱梦44 分钟前
Redis集群部署指南:高可用与分布式实践
数据库·redis·分布式
就是有点傻2 小时前
C#如何实现中英文快速切换
数据库·c#
半新半旧2 小时前
Redis集群和 zookeeper 实现分布式锁的优势和劣势
redis·分布式·zookeeper
1024小神2 小时前
hono框架绑定cloudflare的d1数据库操作步骤
数据库
KellenKellenHao4 小时前
MySQL数据库主从复制
数据库·mysql
@ chen4 小时前
Redis事务机制
数据库·redis
KaiwuDB4 小时前
使用Docker实现KWDB数据库的快速部署与配置
数据库·docker
一只fish5 小时前
MySQL 8.0 OCP 1Z0-908 题目解析(16)
数据库·mysql
泊浮目5 小时前
未来数据库硬件-网络篇
数据库·架构·云计算