如何将.opt .frm .myd,mid文件导入MySQL?

时间:2014-04-15 01:26:03

标签: mysql import database-connection

我有一个数据库,其中包含一个文件.opt和这个数据库中每个实体的三个文件.frm .mid .myd。

任何人都可以帮我将这个数据库导入mySql吗?

由于

1 个答案:

答案 0 :(得分:0)

你的意思是.MYI而不是* .MID。

MySQL中带有扩展名.FRM .MYD .MYI的文件名是MyISAM表。您只需将这些文件复制到数据库文件夹即可。

mysql> create database myDatabase;
Query OK, 1 row affected (0.00 sec)

mysql> quit
Bye

[root@venus cart]# ls tt*.*
tt.frm  tt.MYD  tt.MYI
[root@venus cart]# cp tt.* /var/lib/mysql/myDatabase/
[root@venus cart]# 
[root@venus cart]# 
[root@venus cart]# cd /var/lib/mysql/myDatabase/
[root@venus myDatabase]# ll
total 24
-rw-rw----. 1 mysql mysql   65 Apr 15 10:36 db.opt
-rw-r-----. 1 root  root  8582 Apr 15 10:37 tt.frm
-rw-r-----. 1 root  root    18 Apr 15 10:37 tt.MYD
-rw-r-----. 1 root  root  3072 Apr 15 10:37 tt.MYI
[root@venus myDatabase]# chown mysql.mysql tt.*
[root@venus myDatabase]# ll
total 24
-rw-rw----. 1 mysql mysql   65 Apr 15 10:36 db.opt
-rw-r-----. 1 mysql mysql 8582 Apr 15 10:37 tt.frm
-rw-r-----. 1 mysql mysql   18 Apr 15 10:37 tt.MYD
-rw-r-----. 1 mysql mysql 3072 Apr 15 10:37 tt.MYI
[root@venus myDatabase]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use myDatabase;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SELECT * FROM tt;
+----+------+
| id | c1   |
+----+------+
|  2 |    3 |
|  3 |    2 |
+----+------+
2 rows in set (0.00 sec)
相关问题