I have .frm files from Windows and now I use Ubuntu. How can I create the same table as in Windows from only .frm files? I read that I can just copy paste those files, but in Ubuntu, there is no MySQL/data folder and I have no idea where they store MySQL tables with .frm type files. Thank you.
我有来自Windows的.frm文件,现在我使用Ubuntu。如何仅从.frm文件创建与Windows相同的表?我读到我可以复制粘贴这些文件,但在Ubuntu中,没有MySQL / data文件夹,我不知道他们用.frm类型文件存储MySQL表的位置。谢谢。
2 个解决方案
#1
2
The .frm
file just contains the table format, and is not the entire table. You need the data file as well, which is probably .myd
/.myi
.
.frm文件只包含表格格式,而不是整个表格。您还需要数据文件,可能是.myd / .myi。
Once you do move those files over, be sure to run mysql_upgrade
to ensure that those files you copied will be 100% compatible with the specific version of MySQL you are running.
一旦移动了这些文件,请确保运行mysql_upgrade以确保您复制的那些文件与您运行的特定MySQL版本100%兼容。
#2
2
Wait a minute !!
等一下 !!
Please keep in mind that .frm files contains table description layout only.
请记住,.frm文件仅包含表格描述布局。
If you have all MyISAM tables, then copying the corresponding .MYD and .MYI files to the same folder location as the .frm is sufficient. @Brad already stated this in his answer. (+1 from me on his answer)
如果您拥有所有MyISAM表,则将相应的.MYD和.MYI文件复制到与.frm相同的文件夹位置即可。 @Brad已在他的回答中说明了这一点。 (我的回答是+1)
Now, if the table is InnoDB, moving .frm will not be sufficient. Why?
现在,如果表是InnoDB,那么移动.frm是不够的。为什么?
InnoDB stores four types of info in /var/lib/mysql/ibdata1
InnoDB在/ var / lib / mysql / ibdata1中存储了四种类型的信息
- Data Pages
- Index Pages
- Table MetaData
- MVCC Data
The ibdata1 file must be copied as is to /var/lib/mysql. You must also make sure all setting for innodb in the source DB server's /etc/my.cnf are copied into the /etc/my.cnf of the target DB server.
必须将ibdata1文件原样复制到/ var / lib / mysql。您还必须确保源数据库服务器的/etc/my.cnf中innodb的所有设置都被复制到目标数据库服务器的/etc/my.cnf中。
If any portion of your data is InnoDB, you are much better off performing a mysqldump of all data (except the information_schema and mysql databases) and loading it into a fresh install of MySQL on the target machine.
如果您的数据的任何部分是InnoDB,那么您最好执行所有数据的mysqldump(information_schema和mysql数据库除外)并将其加载到目标计算机上的全新MySQL安装中。
What about the mysql database? There are two ways to port the mysql schema without using mysql_upgrade:
那mysql数据库怎么样?有两种方法可以在不使用mysql_upgrade的情况下移植mysql架构:
OPTION 1 : Use mk-show-grants (or Percona Toolkit's pt-show-grants)
选项1:使用mk-show-grants(或Percona Toolkit的pt-show-grants)
This dumps out all the MySQL Grants as SQL statements, which is completely portable to any MySQL 5.x instance.
这会将所有MySQL Grants转储为SQL语句,它完全可以移植到任何MySQL 5.x实例。
OPTION 2 : Run these commands (My personal emulation of what mk-show-grants does)
选项2:运行这些命令(我个人模拟mk-show-grants的功能)
mysql -hhostaddr -umyuserid -pmypassword --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql -hhostaddr -umyuserid -pmypassword --skip-column-names -A | sed 's/$/;/g' > MySQLUserGrants.sql
The output from either of these methods will result in the GRANT commands for all non-anonymous users (which is version independent). Once the MySQLUserGrants.sql file is made, load that into the target DB server.
这些方法中的任何一个的输出都将为所有非匿名用户(与版本无关)生成GRANT命令。创建MySQLUserGrants.sql文件后,将其加载到目标数据库服务器中。
#1
2
The .frm
file just contains the table format, and is not the entire table. You need the data file as well, which is probably .myd
/.myi
.
.frm文件只包含表格格式,而不是整个表格。您还需要数据文件,可能是.myd / .myi。
Once you do move those files over, be sure to run mysql_upgrade
to ensure that those files you copied will be 100% compatible with the specific version of MySQL you are running.
一旦移动了这些文件,请确保运行mysql_upgrade以确保您复制的那些文件与您运行的特定MySQL版本100%兼容。
#2
2
Wait a minute !!
等一下 !!
Please keep in mind that .frm files contains table description layout only.
请记住,.frm文件仅包含表格描述布局。
If you have all MyISAM tables, then copying the corresponding .MYD and .MYI files to the same folder location as the .frm is sufficient. @Brad already stated this in his answer. (+1 from me on his answer)
如果您拥有所有MyISAM表,则将相应的.MYD和.MYI文件复制到与.frm相同的文件夹位置即可。 @Brad已在他的回答中说明了这一点。 (我的回答是+1)
Now, if the table is InnoDB, moving .frm will not be sufficient. Why?
现在,如果表是InnoDB,那么移动.frm是不够的。为什么?
InnoDB stores four types of info in /var/lib/mysql/ibdata1
InnoDB在/ var / lib / mysql / ibdata1中存储了四种类型的信息
- Data Pages
- Index Pages
- Table MetaData
- MVCC Data
The ibdata1 file must be copied as is to /var/lib/mysql. You must also make sure all setting for innodb in the source DB server's /etc/my.cnf are copied into the /etc/my.cnf of the target DB server.
必须将ibdata1文件原样复制到/ var / lib / mysql。您还必须确保源数据库服务器的/etc/my.cnf中innodb的所有设置都被复制到目标数据库服务器的/etc/my.cnf中。
If any portion of your data is InnoDB, you are much better off performing a mysqldump of all data (except the information_schema and mysql databases) and loading it into a fresh install of MySQL on the target machine.
如果您的数据的任何部分是InnoDB,那么您最好执行所有数据的mysqldump(information_schema和mysql数据库除外)并将其加载到目标计算机上的全新MySQL安装中。
What about the mysql database? There are two ways to port the mysql schema without using mysql_upgrade:
那mysql数据库怎么样?有两种方法可以在不使用mysql_upgrade的情况下移植mysql架构:
OPTION 1 : Use mk-show-grants (or Percona Toolkit's pt-show-grants)
选项1:使用mk-show-grants(或Percona Toolkit的pt-show-grants)
This dumps out all the MySQL Grants as SQL statements, which is completely portable to any MySQL 5.x instance.
这会将所有MySQL Grants转储为SQL语句,它完全可以移植到任何MySQL 5.x实例。
OPTION 2 : Run these commands (My personal emulation of what mk-show-grants does)
选项2:运行这些命令(我个人模拟mk-show-grants的功能)
mysql -hhostaddr -umyuserid -pmypassword --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql -hhostaddr -umyuserid -pmypassword --skip-column-names -A | sed 's/$/;/g' > MySQLUserGrants.sql
The output from either of these methods will result in the GRANT commands for all non-anonymous users (which is version independent). Once the MySQLUserGrants.sql file is made, load that into the target DB server.
这些方法中的任何一个的输出都将为所有非匿名用户(与版本无关)生成GRANT命令。创建MySQLUserGrants.sql文件后,将其加载到目标数据库服务器中。