#!/bin/bash
# 数据库配置
DB_USER="root"
DB_PASSWORD="root"
DB_NAME="adtest1"
DB_HOST="127.0.0.1"
DB_PORT="36826"
# SQL文件路径
SQL_FILE_PATH="/opt/my-ele.sql"
# 创建数据库
mysql -h $DB_HOST -u $DB_USER -p$DB_PASSWORD -P$DB_PORT -e "CREATE DATABASE IF NOT EXISTS $DB_NAME CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
# 导入SQL数据文件
mysql -u "$DB_USER" -p"$DB_PASSWORD" -h "$DB_HOST" -P "$DB_PORT" "$DB_NAME" < "$SQL_FILE_PATH"
如何通过xshell命令 向mysql指定数据库导入sql文件
最新推荐文章于 2024-09-07 22:27:35 发布