Update 2026-06-23 10:40:10
This commit is contained in:
+10
-10
@@ -29,7 +29,7 @@ async function configureDatabase(cmdArgs) {
|
||||
config.dbConfig.port = process.env.MYSQL_PORT || '3306';
|
||||
config.dbConfig.username = process.env.MYSQL_USER || 'root';
|
||||
config.dbConfig.password = process.env.MYSQL_PASSWORD || '';
|
||||
config.dbConfig.database = process.env.MYSQL_DATABASE || 'idc_management';
|
||||
config.dbConfig.database = process.env.MYSQL_DATABASE || 'yunrui_management';
|
||||
log.info(`MySQL 配置: ${config.dbConfig.host}:${config.dbConfig.port}/${config.dbConfig.database}`);
|
||||
} else {
|
||||
const mysqlOption = await select('MySQL 配置方式:', [
|
||||
@@ -74,13 +74,13 @@ async function configureDatabase(cmdArgs) {
|
||||
|
||||
async function configureExistingMySQL() {
|
||||
console.log('\n' + colors.yellow + '请确保 MySQL 服务已启动并创建了数据库' + colors.reset);
|
||||
console.log(colors.gray + '创建数据库命令: CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset + '\n');
|
||||
console.log(colors.gray + '创建数据库命令: CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset + '\n');
|
||||
|
||||
config.dbConfig.host = await ask('MySQL 主机地址', config.dbConfig.host || 'localhost');
|
||||
config.dbConfig.port = await ask('MySQL 端口', config.dbConfig.port || '3306');
|
||||
config.dbConfig.username = await ask('MySQL 用户名', config.dbConfig.username || 'root');
|
||||
config.dbConfig.password = await askPassword('MySQL 密码');
|
||||
config.dbConfig.database = await ask('数据库名称', config.dbConfig.database || 'idc_management');
|
||||
config.dbConfig.database = await ask('数据库名称', config.dbConfig.database || 'yunrui_management');
|
||||
}
|
||||
|
||||
async function installMySQL() {
|
||||
@@ -94,7 +94,7 @@ async function installMySQL() {
|
||||
console.log(' 1. 下载 MySQL: https://dev.mysql.com/downloads/mysql/');
|
||||
console.log(' 2. 或使用 XAMPP/WAMP 等集成环境');
|
||||
console.log(' 3. 安装后创建数据库:');
|
||||
console.log(colors.gray + ' CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset);
|
||||
console.log(colors.gray + ' CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset);
|
||||
return { success: false };
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ async function installMySQL() {
|
||||
config.dbConfig.port = '3306';
|
||||
config.dbConfig.username = 'root';
|
||||
config.dbConfig.password = mysqlRootPassword;
|
||||
config.dbConfig.database = 'idc_management';
|
||||
config.dbConfig.database = 'yunrui_management';
|
||||
|
||||
log.subStep('创建数据库...');
|
||||
await createMySQLDatabase(mysqlRootPassword);
|
||||
@@ -148,7 +148,7 @@ async function installMySQL() {
|
||||
port: '3306',
|
||||
username: 'root',
|
||||
password: mysqlRootPassword,
|
||||
database: 'idc_management'
|
||||
database: 'yunrui_management'
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -191,14 +191,14 @@ async function installMySQLRHEL(rootPassword) {
|
||||
async function createMySQLDatabase(rootPassword) {
|
||||
log.subStep('创建数据库...');
|
||||
|
||||
const createDbSql = 'CREATE DATABASE IF NOT EXISTS idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;';
|
||||
const createDbSql = 'CREATE DATABASE IF NOT EXISTS yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;';
|
||||
|
||||
try {
|
||||
execSync(`mysql -u root -p'${rootPassword}' -e "${createDbSql}"`, {
|
||||
shell: '/bin/bash',
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
});
|
||||
log.success('数据库 idc_management 创建成功');
|
||||
log.success('数据库 yunrui_management 创建成功');
|
||||
return;
|
||||
} catch (error) {
|
||||
const errorMsg = error.stderr ? error.stderr.toString() : error.message;
|
||||
@@ -210,7 +210,7 @@ async function createMySQLDatabase(rootPassword) {
|
||||
shell: '/bin/bash',
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
});
|
||||
log.success('数据库 idc_management 创建成功');
|
||||
log.success('数据库 yunrui_management 创建成功');
|
||||
return;
|
||||
} catch (e2) {
|
||||
log.warning(`无密码连接也失败: ${e2.message}`);
|
||||
@@ -220,7 +220,7 @@ async function createMySQLDatabase(rootPassword) {
|
||||
log.warning(`数据库自动创建失败: ${errorMsg.trim()}`);
|
||||
log.info('请手动创建数据库:');
|
||||
console.log(colors.cyan + ' mysql -u root -p' + colors.reset);
|
||||
console.log(colors.cyan + ' CREATE DATABASE idc_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset);
|
||||
console.log(colors.cyan + ' CREATE DATABASE yunrui_management CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + colors.reset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user