签入版本
This commit is contained in:
@@ -9,15 +9,15 @@
|
||||
```text
|
||||
document/
|
||||
├── mysql/
|
||||
│ └── rxthinkcmf.thinkphp6.elevue.sql # MySQL 版本
|
||||
│ └── rxthinkcmf.thinkphp8.elevue.sql # MySQL 版本
|
||||
├── postgresql/
|
||||
│ └── rxthinkcmf.thinkphp6.elevue.sql # PostgreSQL 版本
|
||||
│ └── rxthinkcmf.thinkphp8.elevue.sql # PostgreSQL 版本
|
||||
├── sqlserver/
|
||||
│ └── rxthinkcmf.thinkphp6.elevue.sql # SQL Server 版本
|
||||
│ └── rxthinkcmf.thinkphp8.elevue.sql # SQL Server 版本
|
||||
├── oracle/
|
||||
│ └── rxthinkcmf.thinkphp6.elevue.sql # Oracle 版本
|
||||
│ └── rxthinkcmf.thinkphp8.elevue.sql # Oracle 版本
|
||||
└── sqlite/
|
||||
└── rxthinkcmf.thinkphp6.elevue.sql # SQLite 版本
|
||||
└── rxthinkcmf.thinkphp8.elevue.sql # SQLite 版本
|
||||
```
|
||||
|
||||
各数据库脚本已针对对应的 SQL 语法做了适配,可直接导入使用,无需手动转换。
|
||||
@@ -37,7 +37,7 @@ mysql -u root -p
|
||||
-- 创建项目数据库
|
||||
-- CHARACTER SET utf8mb4 → 支持 emoji 等四字节字符
|
||||
-- COLLATE utf8mb4_general_ci → 不区分大小写的排序规则
|
||||
CREATE DATABASE `rxthinkcmf.thinkphp6.elevue` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
CREATE DATABASE `rxthinkcmf.thinkphp8.elevue` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
EXIT;
|
||||
```
|
||||
|
||||
@@ -50,7 +50,7 @@ EXIT;
|
||||
# -u root -proot → 数据库用户名和密码
|
||||
# rxthinkcmf... → 目标数据库名
|
||||
# < file.sql → 将 SQL 文件内容作为 mysql 命令的输入
|
||||
mysql -u root -proot rxthinkcmf.thinkphp6.elevue < document/mysql/rxthinkcmf.thinkphp6.elevue.sql
|
||||
mysql -u root -proot rxthinkcmf.thinkphp8.elevue < document/mysql/rxthinkcmf.thinkphp8.elevue.sql
|
||||
```
|
||||
|
||||
:::tip 温馨提示
|
||||
@@ -63,7 +63,7 @@ mysql -u root -proot rxthinkcmf.thinkphp6.elevue < document/mysql/rxthinkcmf.thi
|
||||
[DATABASE]
|
||||
TYPE = mysql ; 数据库类型
|
||||
HOSTNAME = 127.0.0.1 ; 数据库地址
|
||||
DATABASE = rxthinkcmf.thinkphp6.elevue ; 数据库名
|
||||
DATABASE = rxthinkcmf.thinkphp8.elevue ; 数据库名
|
||||
USERNAME = root ; 用户名
|
||||
PASSWORD = root ; 密码
|
||||
HOSTPORT = 3306 ; 端口
|
||||
@@ -88,10 +88,10 @@ CREATE USER postgres WITH PASSWORD 'root';
|
||||
-- 创建项目数据库
|
||||
-- OWNER postgres → 指定数据库所有者
|
||||
-- ENCODING 'UTF8' → 使用 UTF-8 编码
|
||||
CREATE DATABASE "rxthinkcmf.thinkphp6.elevue" OWNER postgres ENCODING 'UTF8';
|
||||
CREATE DATABASE "rxthinkcmf.thinkphp8.elevue" OWNER postgres ENCODING 'UTF8';
|
||||
|
||||
-- 授予用户对该数据库的所有权限
|
||||
GRANT ALL PRIVILEGES ON DATABASE "rxthinkcmf.thinkphp6.elevue" TO postgres;
|
||||
GRANT ALL PRIVILEGES ON DATABASE "rxthinkcmf.thinkphp8.elevue" TO postgres;
|
||||
\q
|
||||
```
|
||||
|
||||
@@ -104,7 +104,7 @@ GRANT ALL PRIVILEGES ON DATABASE "rxthinkcmf.thinkphp6.elevue" TO postgres;
|
||||
# -U postgres → 连接用户
|
||||
# -d ... → 目标数据库
|
||||
# -f file.sql → 执行 SQL 文件
|
||||
psql -U postgres -d rxthinkcmf.thinkphp6.elevue -f document/postgresql/rxthinkcmf.thinkphp6.elevue.sql
|
||||
psql -U postgres -d rxthinkcmf.thinkphp8.elevue -f document/postgresql/rxthinkcmf.thinkphp8.elevue.sql
|
||||
```
|
||||
|
||||
### 3. 配置 .env
|
||||
@@ -113,7 +113,7 @@ psql -U postgres -d rxthinkcmf.thinkphp6.elevue -f document/postgresql/rxthinkcm
|
||||
[DATABASE]
|
||||
TYPE = pgsql ; 数据库类型改为 pgsql
|
||||
HOSTNAME = 127.0.0.1
|
||||
DATABASE = rxthinkcmf.thinkphp6.elevue
|
||||
DATABASE = rxthinkcmf.thinkphp8.elevue
|
||||
USERNAME = postgres ; PostgreSQL 默认用户
|
||||
PASSWORD = root
|
||||
HOSTPORT = 5432 ; PostgreSQL 默认端口
|
||||
@@ -146,7 +146,7 @@ touch /www/api/runtime/database.sqlite
|
||||
# sqlite3 → SQLite 命令行工具
|
||||
# 数据库文件路径 → SQLite 数据库存储在单个文件中
|
||||
# < file.sql → 将 SQL 文件作为输入执行
|
||||
sqlite3 /www/api/runtime/database.sqlite < document/sqlite/rxthinkcmf.thinkphp6.elevue.sql
|
||||
sqlite3 /www/api/runtime/database.sqlite < document/sqlite/rxthinkcmf.thinkphp8.elevue.sql
|
||||
```
|
||||
|
||||
### 3. 配置 .env
|
||||
@@ -179,7 +179,7 @@ PREFIX = think_
|
||||
# -P root → 密码
|
||||
# -Q → 执行 SQL 查询后退出
|
||||
# COLLATE Chinese_PRC_CI_AS → 中文排序规则(不区分大小写)
|
||||
sqlcmd -S localhost -U sa -P root -Q "CREATE DATABASE [rxthinkcmf.thinkphp6.elevue] COLLATE Chinese_PRC_CI_AS"
|
||||
sqlcmd -S localhost -U sa -P root -Q "CREATE DATABASE [rxthinkcmf.thinkphp8.elevue] COLLATE Chinese_PRC_CI_AS"
|
||||
```
|
||||
|
||||
### 2. 导入 SQL 脚本
|
||||
@@ -190,7 +190,7 @@ sqlcmd -S localhost -U sa -P root -Q "CREATE DATABASE [rxthinkcmf.thinkphp6.elev
|
||||
# -----------------------------------------------------------------------------
|
||||
# -d rxthinkcmf... → 目标数据库
|
||||
# -i file.sql → 执行 SQL 文件
|
||||
sqlcmd -S localhost -U sa -P root -d rxthinkcmf.thinkphp6.elevue -i document/sqlserver/rxthinkcmf.thinkphp6.elevue.sql
|
||||
sqlcmd -S localhost -U sa -P root -d rxthinkcmf.thinkphp8.elevue -i document/sqlserver/rxthinkcmf.thinkphp8.elevue.sql
|
||||
```
|
||||
|
||||
### 3. 配置 .env
|
||||
@@ -199,7 +199,7 @@ sqlcmd -S localhost -U sa -P root -d rxthinkcmf.thinkphp6.elevue -i document/sql
|
||||
[DATABASE]
|
||||
TYPE = sqlsrv ; 数据库类型改为 sqlsrv
|
||||
HOSTNAME = 127.0.0.1
|
||||
DATABASE = rxthinkcmf.thinkphp6.elevue
|
||||
DATABASE = rxthinkcmf.thinkphp8.elevue
|
||||
USERNAME = sa ; SQL Server 默认管理员
|
||||
PASSWORD = root
|
||||
HOSTPORT = 1433 ; SQL Server 默认端口
|
||||
@@ -220,15 +220,15 @@ sqlplus system/root@localhost:1521/XE
|
||||
-- DATAFILE → 数据文件的物理路径
|
||||
-- SIZE 100M → 初始大小 100MB
|
||||
-- AUTOEXTEND ON NEXT 100M → 空间不足时自动扩展 100MB
|
||||
CREATE TABLESPACE "rxthinkcmf_thinkphp6_elevue"
|
||||
DATAFILE '/u01/oradata/rxthinkcmf_thinkphp6_elevue.dbf'
|
||||
CREATE TABLESPACE "rxthinkcmf_thinkphp8_elevue"
|
||||
DATAFILE '/u01/oradata/rxthinkcmf_thinkphp8_elevue.dbf'
|
||||
SIZE 100M AUTOEXTEND ON NEXT 100M;
|
||||
|
||||
-- 创建数据库用户
|
||||
-- IDENTIFIED BY → 设置密码
|
||||
-- DEFAULT TABLESPACE → 指定默认表空间
|
||||
CREATE USER "root" IDENTIFIED BY "root"
|
||||
DEFAULT TABLESPACE "rxthinkcmf_thinkphp6_elevue";
|
||||
DEFAULT TABLESPACE "rxthinkcmf_thinkphp8_elevue";
|
||||
|
||||
-- 授权
|
||||
-- CONNECT → 连接权限
|
||||
@@ -249,7 +249,7 @@ EXIT;
|
||||
# sqlplus → Oracle 命令行工具
|
||||
# root/root@localhost:1521/XE → 用户/密码@主机:端口/服务名
|
||||
# @file.sql → 执行 SQL 文件
|
||||
sqlplus root/root@localhost:1521/XE @document/oracle/rxthinkcmf.thinkphp6.elevue.sql
|
||||
sqlplus root/root@localhost:1521/XE @document/oracle/rxthinkcmf.thinkphp8.elevue.sql
|
||||
```
|
||||
|
||||
### 3. 配置 .env
|
||||
@@ -258,7 +258,7 @@ sqlplus root/root@localhost:1521/XE @document/oracle/rxthinkcmf.thinkphp6.elevue
|
||||
[DATABASE]
|
||||
TYPE = oracle ; 数据库类型改为 oracle
|
||||
HOSTNAME = 127.0.0.1
|
||||
DATABASE = rxthinkcmf.thinkphp6.elevue
|
||||
DATABASE = rxthinkcmf.thinkphp8.elevue
|
||||
USERNAME = root
|
||||
PASSWORD = root
|
||||
HOSTPORT = 1521 ; Oracle 默认端口
|
||||
@@ -288,13 +288,13 @@ curl http://localhost:8000/api/login -X POST \
|
||||
# MySQL:查询用户表记录数(验证表是否创建成功且有数据)
|
||||
# -----------------------------------------------------------------------------
|
||||
# -e → 执行 SQL 后退出
|
||||
mysql -u root -proot rxthinkcmf.thinkphp6.elevue -e "SELECT COUNT(*) FROM think_user;"
|
||||
mysql -u root -proot rxthinkcmf.thinkphp8.elevue -e "SELECT COUNT(*) FROM think_user;"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# PostgreSQL:查询用户表记录数
|
||||
# -----------------------------------------------------------------------------
|
||||
# -c → 执行 SQL 命令
|
||||
psql -U postgres -d rxthinkcmf.thinkphp6.elevue -c "SELECT COUNT(*) FROM think_user;"
|
||||
psql -U postgres -d rxthinkcmf.thinkphp8.elevue -c "SELECT COUNT(*) FROM think_user;"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# SQLite:查询用户表记录数
|
||||
@@ -305,7 +305,7 @@ sqlite3 /www/api/runtime/database.sqlite "SELECT COUNT(*) FROM think_user;"
|
||||
# SQL Server:查询用户表记录数
|
||||
# -----------------------------------------------------------------------------
|
||||
# -Q → 执行查询后退出
|
||||
sqlcmd -S localhost -U sa -P root -d rxthinkcmf.thinkphp6.elevue -Q "SELECT COUNT(*) FROM think_user;"
|
||||
sqlcmd -S localhost -U sa -P root -d rxthinkcmf.thinkphp8.elevue -Q "SELECT COUNT(*) FROM think_user;"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Oracle:查询用户表记录数(需先进入 SQL 命令行)
|
||||
@@ -338,7 +338,7 @@ EXIT;
|
||||
|
||||
```bash
|
||||
# --default-character-set=utf8mb4 → 指定字符集为 utf8mb4(支持 emoji)
|
||||
mysql -u root -proot --default-character-set=utf8mb4 rxthinkcmf.thinkphp6.elevue < document/mysql/rxthinkcmf.thinkphp6.elevue.sql
|
||||
mysql -u root -proot --default-character-set=utf8mb4 rxthinkcmf.thinkphp8.elevue < document/mysql/rxthinkcmf.thinkphp8.elevue.sql
|
||||
```
|
||||
|
||||
### Q: 表已存在错误
|
||||
@@ -348,13 +348,13 @@ mysql -u root -proot --default-character-set=utf8mb4 rxthinkcmf.thinkphp6.elevue
|
||||
# 先删除旧数据库再重建(⚠️ 会清空所有数据)
|
||||
# -----------------------------------------------------------------------------
|
||||
# DROP DATABASE IF EXISTS → 如果存在则删除
|
||||
mysql -u root -proot -e "DROP DATABASE IF EXISTS \`rxthinkcmf.thinkphp6.elevue\`;"
|
||||
mysql -u root -proot -e "DROP DATABASE IF EXISTS \`rxthinkcmf.thinkphp8.elevue\`;"
|
||||
|
||||
# 创建数据库(指定字符集)
|
||||
mysql -u root -proot -e "CREATE DATABASE \`rxthinkcmf.thinkphp6.elevue\` DEFAULT CHARACTER SET utf8mb4;"
|
||||
mysql -u root -proot -e "CREATE DATABASE \`rxthinkcmf.thinkphp8.elevue\` DEFAULT CHARACTER SET utf8mb4;"
|
||||
|
||||
# 重新导入 SQL
|
||||
mysql -u root -proot rxthinkcmf.thinkphp6.elevue < document/mysql/rxthinkcmf.thinkphp6.elevue.sql
|
||||
mysql -u root -proot rxthinkcmf.thinkphp8.elevue < document/mysql/rxthinkcmf.thinkphp8.elevue.sql
|
||||
```
|
||||
|
||||
### Q: PostgreSQL 导入报错
|
||||
|
||||
Reference in New Issue
Block a user