MySQL database Import Export command More common is the use of mysqldump source these two commands. This article shares a different, faster and more convenient way to import and export data.
(1) Export data
A, use the default path
SELECT * from data table name into outfile ' text name. txt ';
Example:
/* The data in the Phpernote table is exported and saved to the C-disk directory, save as a phpernote.txt file * *
SELECT * from Phpernote into outfile ' c:\phpernote.txt ';
b, specify the path to store
SELECT * from data table name into outfile ' d:\ text name. txt ';
C, export the fields specified by the datasheet
Select Field Name 1, field name 2 From data table name into outfile ' text name. txt ';
(2) Import data
A, the record contains all the fields of the datasheet
Load Data infile ' text name. txt path ' into table table name; Import record contains all fields
B, the record contains the data table specified fields
Load Data infile ' text name. txt ' into table datasheet name (field name 1, field name 2)
Note: the sort of field names should be sorted in accordance with the specified field names exported
The following error may be encountered when customizing the stored path:
Mysql> SELECT * from patent into outfile '/home/a ';
ERROR 1 (HY000): Can ' t create/write to file '/home/a ' (errcode:13)
Again, refer to a solution:
Obviously, this is due to permission issues, and the main problem is figuring out how permissions are set.
Ubuntu uses AppArmor as a program permission limit, and Fedora uses SELinux as a program permission limit. In Linux, the previous rights management, through the user-bound, now there is a privilege mechanism to set the program access rights, such as:
sudo mysqldump--t db; If you do not start the program Rights Management, mysqldump get root permissions, you can operate in any file.
sudo mysqldump-t db; if AppArmor is enabled in Ubuntu, even root permissions are qualified according to the program's access rights.
So we can add the directories that need to be accessed to the AppArmor configuration file:
sudo gedit/etc/apparmor.d/usr.sbin.mysqld
Add the following:
/data/* RW,
Then, Sudo/etc/init.d/apparmor restart
I'm just looking for a usr.sbin.mysqld directory (/var/log/mysql/) in the right place, because the custom directory doesn't seem to work.
jesse@jesse-desktop:/var/log/mysql$