How can I convert an MDB (Access) file to MySQL (or plain SQL file)?

后端 未结 4 652
后悔当初
后悔当初 2020-12-07 07:47

Is it possible to create a Dump of SQL commands from a Microsoft Access database? I hope to convert this MDB file into a MySQL database for importing so I don\'t have to go

4条回答
  •  隐瞒了意图╮
    2020-12-07 08:27

    I modified the script by Nicolay77 to output the database to stdout (the usual way of unix scripts) so that I could output the data to text file or pipe it to any program I want. The resulting script is a bit simpler and works well.

    Some examples:

    ./mdb_to_mysql.sh database.mdb > data.sql
    
    ./mdb_to_mysql.sh database.mdb | mysql destination-db -u user -p
    

    Here is the modified script (save to mdb_to_mysql.sh)

    #!/bin/bash
    TABLES=$(mdb-tables -1 $1)
    
    for t in $TABLES
    do
        echo "DROP TABLE IF EXISTS $t;"
    done
    
    mdb-schema $1 mysql
    
    for t in $TABLES
    do
        mdb-export -D '%Y-%m-%d %H:%M:%S' -I mysql $1 $t
    done
    

提交回复
热议问题