本文主要就是我在使用Qt的时候需要用到access数据库里的信息,但是我安装的Qt版本不支持access数据库的开发,所以我想到将access数据库中的内容导入到mysql中进行使用,以下是我上网查过资料实践的总结(都为个人理解,有不妥之处,还望有大神指点):
1.第一步将access数据库中的数据导出到一个.txt文件,然后将这个txt文件拷到linux系统/var/lib/mysql/下
2.然后使用linux下的mysqlimport(主要是将文本文件中的信息导入mysql数据库中)
例:我要将student.txt的信息导入到mysql中的Student的student表中(记住txt的名字要和要导入的表名一致)
cp /root/test/Qt/MessageStudent/student.txt /var/lib/mysql/Student/
之后
mysqlimport -r --fields-enclosed-by='"' --fields-terminated-by=',' Student student.txt
mysqlimport -?
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read
--character-sets-dir=name
Directory where character sets are.
--default-character-set=name
Set the default character set.
-c, --columns=name Use only these columns to import the data to. Give the
column names in a comma separated list. This is same as
giving columns to LOAD DATA INFILE.
-C, --compress Use compression in server/client protocol.
-#, --debug[=name] Output debug log. Often this is 'd:t:o,filename'.
-d, --delete First delete all rows from table.
--fields-terminated-by=name
Fields in the textfile are terminated by ...
--fields-enclosed-by=name
Fields in the importfile are enclosed by ...
--fields-optionally-enclosed-by=name
Fields in the i.file are opt. enclosed by ...
--fields-escaped-by=name
Fields in the i.file are escaped by ...
-f, --force Continue even if we get an sql-error.
-?, --help Displays this help and exits.
-h, --host=name Connect to host.
-i, --ignore If duplicate unique key was found, keep old row.
--ignore-lines=# Ignore first n lines of data infile.
--lines-terminated-by=name
Lines in the i.file are terminated by ...
-L, --local Read all files through the client.
-l, --lock-tables Lock all tables for write.
--low-priority Use LOW_PRIORITY when updating the table.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty.
-P, --port=# Port number to use for connection.
--protocol=name The protocol of connection (tcp,socket,pipe,memory).
-r, --replace If duplicate unique key was found, replace old row.
-s, --silent Be more silent.
-S, --socket=name Socket file to use for connection.
--ssl Enable SSL for connection (automatically enabled with
other flags). Disable with --skip-ssl.
--ssl-ca=name CA file in PEM format (check OpenSSL docs, implies
--ssl).
--ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).
--ssl-cert=name X509 cert in PEM format (implies --ssl).
--ssl-cipher=name SSL cipher to use (implies --ssl).
--ssl-key=name X509 key in PEM format (implies --ssl).
--ssl-verify-server-cert
Verify server's "Common Name" in its cert against
hostname used when connecting. This option is disabled by
default.
-u, --user=name User for login if not current user.
-v, --verbose Print info about the various stages.
-V, --version Output version information and exit.