|
@@ -0,0 +1,59 @@
|
|
|
+/**
|
|
|
+ * 数据库连接配置
|
|
|
+ *
|
|
|
+ * 注意:为避免交互式操作,请在MySQL命令中直接包含密码参数
|
|
|
+ * 正确用法:mysql -h host -P port -u user -ppassword -D database -e "SQL语句"
|
|
|
+ * 错误用法:mysql -h host -P port -u user -p -D database -e "SQL语句" (会提示输入密码)
|
|
|
+ */
|
|
|
+
|
|
|
+// MySQL数据库连接配置
|
|
|
+export const DATABASE_CONFIG = {
|
|
|
+ // 数据库连接信息
|
|
|
+ host: '10.tcp.cpolar.top',
|
|
|
+ port: 14934,
|
|
|
+ user: 'root',
|
|
|
+ password: 'root',
|
|
|
+ database: 'blade',
|
|
|
+
|
|
|
+ // 连接字符串模板(用于命令行操作)
|
|
|
+ getConnectionString() {
|
|
|
+ return `mysql -h ${this.host} -P ${this.port} -u ${this.user} -p${this.password} -D ${this.database}`;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取执行SQL的完整命令
|
|
|
+ getQueryCommand(sql) {
|
|
|
+ return `${this.getConnectionString()} -e "${sql}"`;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 常用查询命令示例
|
|
|
+ examples: {
|
|
|
+ // 显示所有表
|
|
|
+ showTables: 'SHOW TABLES;',
|
|
|
+
|
|
|
+ // 查看订单表结构
|
|
|
+ describeOrderTable: 'DESCRIBE pc_blade_order;',
|
|
|
+
|
|
|
+ // 查看订单明细表结构
|
|
|
+ describeOrderItemTable: 'DESCRIBE pc_blade_order_item;',
|
|
|
+
|
|
|
+ // 查看客户地址表结构
|
|
|
+ describeCustomerAddressTable: 'DESCRIBE pc_blade_customer_address;'
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 默认导出配置
|
|
|
+export default DATABASE_CONFIG;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 使用示例:
|
|
|
+ *
|
|
|
+ * import { DATABASE_CONFIG } from './config/database.js';
|
|
|
+ *
|
|
|
+ * // 获取连接字符串
|
|
|
+ * const connectionString = DATABASE_CONFIG.getConnectionString();
|
|
|
+ *
|
|
|
+ * // 执行查询
|
|
|
+ * const queryCommand = DATABASE_CONFIG.getQueryCommand('SHOW TABLES;');
|
|
|
+ * console.log(queryCommand);
|
|
|
+ * // 输出: mysql -h 10.tcp.cpolar.top -P 14934 -u root -proot -D blade -e "SHOW TABLES;"
|
|
|
+ */
|