数据库配置
FeedbackPulse SaaS 使用 MySQL 或 MariaDB 作为主数据库。
✅ 支持的数据库
| 数据库 | 版本 | 状态 |
|---|---|---|
| MySQL | 8.0+ | ✅ 完全支持(推荐) |
| MariaDB | 10.6+ | ✅ 完全支持 |
| PostgreSQL | 15+ | ⚠️ 实验性(迁移可能需要调整) |
| SQLite | 3.35+ | ⚠️ 仅限开发环境(不适用于生产) |
🔧 创建数据库
在运行安装程序之前:
-- Connect to MySQL
mysql -u root -p
-- Create database with proper character set
CREATE DATABASE feedbackpulse
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
-- Create a dedicated user (recommended for security)
CREATE USER 'feedbackpulse'@'localhost'
IDENTIFIED BY 'your_strong_password_here';
-- Grant permissions
GRANT ALL PRIVILEGES ON feedbackpulse.*
TO 'feedbackpulse'@'localhost';
FLUSH PRIVILEGES;
EXIT;
⚠️ 为什么使用
utf8mb4? 它支持完整的 Unicode 字符集,包括表情符号。客户反馈中通常包含表情符号,因此这一点非常重要!
⚙️ .env 配置
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=feedbackpulse
DB_USERNAME=feedbackpulse
DB_PASSWORD=your_strong_password_here
常见问题
| 问题 | 解决方案 |
|---|---|
SQLSTATE[HY000] [2002] Connection refused | 使用 127.0.0.1 代替 localhost |
SQLSTATE[HY000] [1045] Access denied | 检查用户名/密码,确保用户具有相应权限 |
SQLSTATE[42S01] Table already exists | 数据库不为空。请先删除并重新创建,或使用 --force 参数 |
表情符号显示为 ???? | 数据库字符集必须是 utf8mb4,而非 utf8 |
🔍 MySQL 性能调优
对于拥有多个租户的生产服务器,请优化 MySQL:
# /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
# InnoDB buffer pool (set to 50-70% of available RAM)
innodb_buffer_pool_size = 1G
# Log file size
innodb_log_file_size = 256M
# Max connections (increase for high-traffic platforms)
max_connections = 200
# Query cache (disable in MySQL 8.0+, it's deprecated)
query_cache_type = 0
# Slow query log (for debugging performance issues)
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
重启 MySQL:
sudo systemctl restart mysql