首页
统计
留言
友链
更多
图片
关于
Search
1
设置 Git 全局代理
49 阅读
2
软件开发 | flutter使用camera插件在安卓11以上的机器上调用availableCameras无法正常获得usb相机列表
48 阅读
3
scoop包管理器
47 阅读
4
Word图片压缩
45 阅读
5
利用深度搜索求解回溯问题的通用模板
45 阅读
默认分类
测试
技术开发
杂项
技术分享
相关配置
后端开发
异常处理
软件开发
登录
Search
标签搜索
java
golang
scoop
mysql
flutter
git
vue
hexo
sublime text
cpp
windows
redis
mc
mod
fabric
word
计算机网络
go
html
camera
Wisansiiz
累计撰写
32
篇文章
累计收到
2
条评论
首页
栏目
默认分类
测试
技术开发
杂项
技术分享
相关配置
后端开发
异常处理
软件开发
页面
统计
留言
友链
图片
关于
搜索到
5
篇与
的结果
2026-08-23
Scoop 数据库安装、Windows 服务与认证配置指南
Scoop 数据库安装、Windows 服务与认证配置指南本文记录在 Windows 上通过 Scoop 安装 MySQL LTS、PostgreSQL 和 Redis,并将它们配置为本机自动启动服务、启用密码认证和持久化数据的完整操作。适用场景:个人开发机、本地测试环境。Redis Windows 构建不建议作为生产部署方案;生产环境优先使用 Linux、容器或托管数据库。1. 当前部署状态数据库版本Windows 服务地址认证状态MySQL LTS9.7.2MySQL127.0.0.1:3306root 密码认证PostgreSQL18.6PostgreSQL127.0.0.1:5432scram-sha-256Redis8.10.1Redis127.0.0.1:6379ACL 密码认证三个服务均设置为 Automatic,并且只面向本机监听。主要持久化目录:D:\Scoop\persist\mysql-lts ├── data └── my.ini D:\Scoop\persist\postgresql └── data D:\Scoop\persist\redis ├── dump.rdb ├── redis.conf ├── users.acl └── service-runtime-8.10.12. 安装与更新 Scoop 软件包普通 PowerShell:scoop install mysql-lts postgresql redis查看安装状态和可用更新:scoop list scoop info mysql-lts scoop info postgresql scoop info redis更新三个数据库程序:scoop update mysql-lts postgresql redis不要在可复用脚本中假定 Scoop 一定安装在 D:\Scoop,可动态查询路径:$mysqlRoot = scoop prefix mysql-lts $postgresRoot = scoop prefix postgresql $redisRoot = scoop prefix redis3. MySQL LTS3.1 配置持久化与本机监听配置文件:D:\Scoop\persist\mysql-lts\my.ini[mysqld] datadir=D:/Scoop/persist/mysql-lts/data bind-address=127.0.0.1 mysqlx-bind-address=127.0.0.1 port=3306 [client] user=rootScoop 的 mysql-lts manifest 会持久化 data 和 my.ini,更新程序时不应重新初始化已有数据目录。3.2 注册 Windows 服务在管理员 PowerShell 中执行:$mysqlRoot = scoop prefix mysql-lts $mysqlIni = 'D:\Scoop\persist\mysql-lts\my.ini' & "$mysqlRoot\bin\mysqld.exe" ` --install MySQL ` "--defaults-file=$mysqlIni" Set-Service MySQL -StartupType Automatic Start-Service MySQL Get-Service MySQL服务命令使用 current 路径时,Scoop 更新后会通过目录链接指向新版本。3.3 设置或验证 root 密码连接时使用交互式密码提示,避免密码出现在命令历史和进程参数中:mysql --protocol=TCP --host=127.0.0.1 --port=3306 --user=root -p全新初始化且 root 尚无密码时,可在登录后执行:ALTER USER 'root'@'localhost' IDENTIFIED BY '替换为强密码';如果无密码登录返回 ERROR 1045,说明数据目录中的 root 已经设置过密码。除非确认需要重置,否则不要使用 --skip-grant-tables 覆盖未知密码,以免现有应用断连。3.4 创建应用账户应用程序不要直接使用 root。进入 MySQL 后执行:CREATE DATABASE app_db CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; CREATE USER 'app_user'@'localhost' IDENTIFIED BY '替换为独立强密码'; GRANT ALL PRIVILEGES ON app_db.* TO 'app_user'@'localhost'; SHOW GRANTS FOR 'app_user'@'localhost';连接示例:mysql://app_user:<password>@127.0.0.1:3306/app_db4. PostgreSQL4.1 注册 Windows 服务在管理员 PowerShell 中执行:$postgresRoot = scoop prefix postgresql $postgresData = 'D:\Scoop\persist\postgresql\data' & "$postgresRoot\bin\pg_ctl.exe" register ` -N PostgreSQL ` -D $postgresData ` -S auto Start-Service PostgreSQL Get-Service PostgreSQL4.2 设置管理员密码Scoop 首次初始化通常允许本机 trust 登录。先连接:psql --host=127.0.0.1 --port=5432 --username=postgres --dbname=postgres在 psql 中通过交互式提示设置密码:\password postgres4.3 强制使用 SCRAM 密码认证编辑:D:\Scoop\persist\postgresql\data\pg_hba.conf把本机规则中的 trust 改成 scram-sha-256:local all all scram-sha-256 host all all 127.0.0.1/32 scram-sha-256 host all all ::1/128 scram-sha-256 local replication all scram-sha-256 host replication all 127.0.0.1/32 scram-sha-256 host replication all ::1/128 scram-sha-256重新加载配置:$postgresRoot = scoop prefix postgresql & "$postgresRoot\bin\pg_ctl.exe" reload ` -D 'D:\Scoop\persist\postgresql\data'验证密码登录:psql --host=127.0.0.1 --port=5432 --username=postgres --dbname=postgres4.4 创建应用账户进入 psql 后:CREATE ROLE app_user LOGIN; \password app_user CREATE DATABASE app_db OWNER app_user;连接示例:postgresql://app_user:<password>@127.0.0.1:5432/app_db5. Redis5.1 Scoop Windows 包的服务包装器问题当前 redis manifest 下载普通的 msys2.zip,其中没有 README 提到的 RedisService.exe。同一发布页另有 msys2-with-Service.zip 资产。本机采用以下组合:Redis 主程序由 Scoop 安装和更新。使用同版本官方发布资产中的 RedisService.exe 注册 Windows 服务。数据、配置、ACL 和服务运行时全部放在 D:\Scoop\persist\redis。项目与发布页:https://github.com/redis-windows/redis-windowshttps://github.com/redis-windows/redis-windows/releases/tag/8.10.1Redis 8.10.1 with-Service 资产:https://github.com/redis-windows/redis-windows/releases/download/8.10.1/Redis-8.10.1-Windows-x64-msys2-with-Service.zip SHA-256: 8D7710C858EB9EF24685D040272FA42F6B045906CBAB14DC635697A20303AF1B下载后必须核验:$zip = "$env:TEMP\Redis-8.10.1-Windows-x64-msys2-with-Service.zip" $expected = '8D7710C858EB9EF24685D040272FA42F6B045906CBAB14DC635697A20303AF1B' curl.exe -L ` 'https://github.com/redis-windows/redis-windows/releases/download/8.10.1/Redis-8.10.1-Windows-x64-msys2-with-Service.zip' ` -o $zip $actual = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash if ($actual -ne $expected) { throw "Redis archive hash mismatch: $actual" }5.2 建立持久化目录管理员 PowerShell:$redisRoot = scoop prefix redis $redisPersist = 'D:\Scoop\persist\redis' New-Item -ItemType Directory -Path $redisPersist -Force | Out-Null if (Test-Path "$redisRoot\dump.rdb") { Copy-Item "$redisRoot\dump.rdb" "$redisPersist\dump.rdb" -Force } Copy-Item "$redisRoot\redis.conf" "$redisPersist\redis.conf" -Force核心配置:D:\Scoop\persist\redis\redis.confbind 127.0.0.1 -::1 protected-mode yes port 6379 dir D:/Scoop/persist/redis dbfilename dump.rdb logfile "" aclfile D:/Scoop/persist/redis/users.acl5.3 创建默认 ACL 密码Redis ACL 文件可以保存密码的 SHA-256,而不是明文密码。管理员 PowerShell 示例:$secure = Read-Host 'Redis default password' -AsSecureString $pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure) try { $plain = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer) $bytes = [Text.Encoding]::UTF8.GetBytes($plain) $hash = [Convert]::ToHexString( [Security.Cryptography.SHA256]::HashData($bytes) ).ToLowerInvariant() $aclLine = "user default on #$hash ~* &* +@all`n" [IO.File]::WriteAllText( 'D:\Scoop\persist\redis\users.acl', $aclLine, [Text.UTF8Encoding]::new($false) ) } finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer) Remove-Variable plain -ErrorAction SilentlyContinue }5.4 注册 Redis 服务将 with-Service 压缩包内容解压到类似目录:D:\Scoop\persist\redis\service-runtime-8.10.1管理员 PowerShell:$wrapper = 'D:\Scoop\persist\redis\service-runtime-8.10.1\RedisService.exe' $config = 'D:\Scoop\persist\redis\redis.conf' & $wrapper install ` -c $config ` --service-name Redis ` --display-name 'Redis Database Server (Scoop)' ` --description 'Redis Database Server (Scoop, official RedisService wrapper)' ` --start-mode auto Start-Service Redis Get-Service Redis验证认证:redis-cli --host 127.0.0.1 --port 6379 --user default --askpass ping成功结果:PONG5.5 创建应用 ACL 用户先使用默认管理员账户连接:redis-cli --host 127.0.0.1 --port 6379 --user default --askpass在 Redis CLI 中创建应用用户并保存 ACL:ACL SETUSER app_user on >替换为独立强密码 ~app:* +@read +@write +ping ACL SAVE ACL LIST~app:* 限制用户只能访问 app: 前缀的键。根据应用需要继续缩小命令权限,不要在生产环境直接授予 +@all。连接示例:redis://app_user:<password>@127.0.0.1:6379/06. 服务管理与验证查看状态:Get-Service MySQL,PostgreSQL,Redis启动、停止和重启:Start-Service MySQL,PostgreSQL,Redis Stop-Service MySQL,PostgreSQL,Redis Restart-Service MySQL,PostgreSQL,Redis查看服务实际启动命令:sc.exe qc MySQL sc.exe qc PostgreSQL sc.exe qc Redis客户端连接测试:mysql --host=127.0.0.1 --port=3306 --user=root -p psql --host=127.0.0.1 --port=5432 --username=postgres --dbname=postgres redis-cli --host 127.0.0.1 --port 6379 --user default --askpass ping查看端口监听情况需要管理员权限:Get-NetTCPConnection -State Listen -LocalPort 3306,5432,63797. 凭据管理本机凭据文件:C:\Users\Wisansiiz\.config\database-services\credentials.txt建议:不要把真实密码写入本仓库、Git、README 或共享脚本。应用使用独立低权限账户,不直接使用 root、postgres 或 Redis default。开发框架优先通过系统环境变量、.env.local 或密码管理器读取连接信息。.env* 应加入 .gitignore,提交前使用 git diff --cached 再检查一次。如果凭据曾出现在聊天、终端历史或日志中,按已泄漏处理并轮换。8. 更新、备份和升级注意事项更新前备份MySQL:mysqldump --host=127.0.0.1 --user=root -p ` --all-databases --single-transaction ` --result-file=mysql-all.sqlPostgreSQL:pg_dumpall --host=127.0.0.1 --username=postgres ` --file=postgres-all.sqlRedis:redis-cli --host 127.0.0.1 --port 6379 --user default --askpass save Copy-Item 'D:\Scoop\persist\redis\dump.rdb' '.\redis-dump-backup.rdb'版本升级MySQL 和 PostgreSQL 的 Scoop manifest 已声明数据目录持久化,但更新前仍应备份。PostgreSQL 跨主版本升级不能仅把旧数据目录指向新程序;应使用 pg_upgrade 或逻辑备份与恢复。Redis Scoop manifest 没有声明 dump.rdb、配置和 ACL 的持久化,因此必须继续使用独立的 D:\Scoop\persist\redis。Redis 更新后,需要取得相同新版本的 with-Service 资产、验证哈希、更新 service-runtime-<version>,然后重新注册服务。9. 常见问题MySQL 返回 ERROR 1045这通常表示 root 已有密码,不代表服务启动失败。先使用现有密码连接,不要直接重置授权表。Redis 报配置路径不存在普通 redis-server.exe 基于 MSYS2/Cygwin,命令行中的 Windows 路径可能被错误拼接。直接运行时应使用:/cygdrive/d/Scoop/persist/redis/redis.conf注册服务时优先使用同版本 RedisService.exe,由包装器处理路径转换。Redis 报 Can't open the log file服务模式应使用绝对路径,或者设置:logfile ""让服务管理器接管标准输出日志。Redis 服务长期停在 StopPending这是 NSSM 包装 MSYS2 Redis 时可能出现的停止兼容问题。本机最终方案已改用 Redis Windows 发布项目自带的 RedisService.exe。PowerShell 输出 PSReadLine prediction 警告在输出被重定向或无虚拟终端的会话中,Set-PSReadLineOption -PredictionSource History 可能提示无法启用预测。这与数据库安装、服务注册和运行状态无关。10. 移除服务执行前先完成数据备份。以下操作只删除 Windows 服务定义,不应直接删除持久化数据目录。管理员 PowerShell:Stop-Service MySQL,PostgreSQL,Redis & "$(scoop prefix mysql-lts)\bin\mysqld.exe" --remove MySQL & "$(scoop prefix postgresql)\bin\pg_ctl.exe" unregister -N PostgreSQL & 'D:\Scoop\persist\redis\service-runtime-8.10.1\RedisService.exe' ` uninstall --service-name Redis确认服务定义已经移除后,再决定是否执行 Scoop 卸载:scoop uninstall mysql-lts postgresql redis不要在没有备份和确认路径的情况下递归删除 D:\Scoop\persist\mysql-lts、postgresql 或 redis。
2026年08月23日
3 阅读
0 评论
0 点赞
2026-03-28
入坑mac-1
macOS 包管理器 Homebrew 完全配置指南前言Homebrew 是 macOS 上最受欢迎的包管理工具,被誉为"macOS 缺失的包管理器"。本文将详细介绍 Homebrew 的安装、配置以及常用命令,帮你快速搭建开发环境。一、Homebrew 是什么Homebrew 可以让你轻松安装和管理 macOS 原生没有预装的工具和软件,比如命令行工具(git、node、python 等)、macOS 应用(通过 Homebrew Cask)以及开发库和依赖。二、安装 Homebrew方法一:官方安装(需要梯子)/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"方法二:国内镜像安装(推荐)如果你在大陆地区,官方安装可能很慢,可以使用国内镜像:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"这个脚本由国内开发者维护,会自动配置清华/中科大等镜像源,下载速度会快很多。验证安装brew doctor三、配置 PATH 环境变量安装完成后,需要将 Homebrew 的路径添加到配置文件:# 编辑配置文件(以 zsh 为例) nano ~/.zshrc # Apple Silicon Mac 添加 eval "$(/opt/homebrew/bin/brew shellenv)" # Intel Mac 添加 # eval "$(/usr/local/bin/brew shellenv)" # 使配置生效 source ~/.zshrc四、常用命令安装与管理包# 安装包 brew install git brew install nodejs # 卸载包 brew uninstall git # 查看已安装的包 brew list # 搜索包 brew search gitHomebrew Cask(安装 GUI 应用)# 安装 GUI 应用 brew install --cask visual-studio-code brew install --cask google-chrome # 卸载 GUI 应用 brew uninstall --cask visual-studio-code五、实用技巧批处理安装常用工具# 一次性安装多个包 brew install git node python go # 一次性安装多个 GUI 应用 brew install --cask visual-studio-code google-chrome其他常用命令# 更新 Homebrew 自身 brew update # 升级所有包 brew upgrade # 查看过时包 brew outdated # 清理旧版本 brew cleanup六、常见问题Q: Intel 和 Apple Silicon Mac 有什么区别?Mac 类型Homebrew 安装路径Intel Mac/usr/local/Apple Silicon/opt/homebrew/Q: Homebrew 命令找不到?source ~/.zshrc七、推荐安装的开发工具# 版本管理 brew install git gh # Node.js 生态 brew install node npm # Python brew install python pyenv # 容器 brew install --cask docker # 编辑器 brew install --cask visual-studio-code jetbrains-toolbox
2026年03月28日
2 阅读
0 评论
0 点赞
2026-02-20
goFrame配置文件的参数
goFrame配置文件的参数项目config# https://goframe.org/docs/web/server-config-file-template server: address: ":8000" openapiPath: "/api.json" swaggerPath: "/swagger" # https://goframe.org/docs/core/glog-config logger: level: "all" stdout: true path: "resource/log" rotate: "daily" rotateBackupLimit: 7 rotateBackupExpire: "7d" rotateBackupCompress: 9 # https://goframe.org/docs/core/gdb-config-file database: logger: - path: "resource/log/sql" level: "all" stdout: true default: link: "pgsql:postgres:postgres@tcp(127.0.0.1:5432)/go_admin" debug: true gToken: # 缓存模式 1 gcache 2 gredis 3 gfile cacheMode: 2 # 是否支持多端登录 multiLogin: true redis: default: address: 127.0.0.1:6379 db: 0 pass: 123456 cache: address: 127.0.0.1:6379 db: 1 pass: 123456 idleTimeout: 600rbac config[request_definition] r = sub, obj, act [policy_definition] p = sub, obj, act [role_definition] g = _, _ [policy_effect] e = some(where (p.eft == allow)) [matchers] m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)
2026年02月20日
43 阅读
0 评论
0 点赞
2024-07-14
sublime-text中clang-format插件的配置
Custom style{ "BasedOnStyle": "Google", "IndentWidth": 4, "AlignAfterOpenBracket": true, "AlignConsecutiveAssignments": true, //# 连续声明时,对齐所有声明的变量名 "AlignConsecutiveDeclarations": false, "MaxEmptyLinesToKeep": 4, "BreakBeforeBraces": "Attach", "AllowShortIfStatementsOnASingleLine": true, "IndentCaseLabels": true, "ObjCBlockIndentWidth": 4, "ObjCSpaceAfterProperty": true, "ColumnLimit": 0, "AlignTrailingComments": true, "SpaceAfterCStyleCast": true, "SpacesInParentheses": false, "SpacesInSquareBrackets": false, "TabWidth": 4, "UseTab": "Never", "AllowShortBlocksOnASingleLine": false, "AllowShortIfStatementsOnASingleLine": true, "AllowShortLoopsOnASingleLine": true, "BraceWrapping":{ "AfterClass": false, "AfterControlStatement": false, "AfterEnum": false, "AfterFunction": false, "AfterNamespace": false, "AfterObjCDeclaration": false, "AfterStruct": false, "AfterUnion": false, "BeforeCatch": false, "BeforeElse": false, "IndentBraces": false, "SplitEmptyFunction": true, "SplitEmptyRecord": true, "SplitEmptyNamespace": true }, "Cpp11BracedListStyle": true, "ColumnLimit": 80, } User setting{ "binary": "D:\\LLVM\\bin\\clang-format.exe", "style": "Custom", "format_on_save": true, "languages": ["C", "C++"] }
2024年07月14日
16 阅读
0 评论
0 点赞
2024-06-06
codeforces-cpp模板
codeforces-cpp模板#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mk make_pair #define endl "\n" #define enld "\n" #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define LCM(a, b) a *b / __gcd(a, b) #define GCD(a, b) __gcd(a, b) #define len(v) int(v.size()) #define all(v) v.begin(), v.end() #define sz 100010 #define mod 1000000007 #define inf 1e18 #define i32 1e9 typedef long long ll; typedef unsigned long long ull; typedef double ld; typedef long double lld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<pii> vpii; typedef vector<ll> vll; typedef vector<ld> vd; void solve() { int n; cin >> n; cout << n << endl; } int main() { fastio; int t = 1; cin >> t; while (t--) solve(); }
2024年06月06日
21 阅读
0 评论
0 点赞