树莓派安装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 客户端工具打开连接成功

你可能感兴趣的:(环境搭建篇,mariadb,redis,数据库)