mdb 数据库如何导入 msyql
mdb文件是一种数据库文件,可以使用微软的 acess 打开。一些asp 或者 .net 的网站也可能用到。不过性能不高,数量一多,就会反应慢。所以有个需求把 mdb 数据库如何导入 msyql。
安装 mdbtools 工具
apt install mdbtools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libmdb2 libmdbsql2
Suggested packages:
mdbtools-doc
The following NEW packages will be installed:
libmdb2 libmdbsql2 mdbtools
0 upgraded, 3 newly installed, 0 to remove and 25 not upgraded.
Need to get 159 kB of archives.
After this operation, 426 kB of additional disk space will be used.
Do you want to continue? [Y/n]
查看mdbtools 都有提供了什么工具
mdb-
mdb-array mdb-hexdump mdb-schema mdb-ver
mdb-export mdb-parsecsv mdb-sql
mdb-header mdb-prop mdb-tables
导入的脚本 mdb2mysql.sh
#!/bin/bash
TABLES=$(mdb-tables -1 $1)
MDB="$2"
MYSQL=$(which mysql)
for t in $TABLES
do
$MYSQL $MDB -e "DROP TABLE IF EXISTS $t"
done
# 导入表结构
mdb-schema $1 mysql | $MYSQL $MDB
# 导入数据表
for t in $TABLES
do
mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $1 $t | $MYSQL $MDB
done
###
chmod +x mdb2mysql.sh
./mdb2mysql.sh you-file.mdb you-dbname