简体   繁体   中英

how to import .opt .frm .myd ,mid files to MySQL?

I have a data base that includes one file .opt and a three files .frm .mid .myd for each entity in this DB.

can anyone help me with importing this data base to mySql?

Thanks

Do you mean .MYI instead of *.MID.

Filename with extensions .FRM .MYD .MYI in MySQL are MyISAM Tables. You can just simply copy these files into database folder.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM