12345678910111213141516171819202122232425262728 |
- #!/bin/bash
- # Ubuntu 22.04 文件格式和 Win 不同!
- #
- # 安装转码工具
- # sudo apt install dos2unix
- #
- # 转码
- # sudo dos2unix import_ubuntu.sh
- #
- # 执行
- # sudo sh import_ubuntu.sh
- # MySQL 8.x 登录凭据
- username="root"
- password="xxxxxxxx"
- database="backendsys"
- # SQL文件所在的目录
- sql_dir="/home/www/project/BackendSys/db/"
- # 遍历目录中的所有.sql文件
- for file in ${sql_dir}*.sql; do
- echo "Importing file: $file"
- mysql -u $username -p$password $database < $file
- done
- echo "All SQL files have been imported."
|