I wrote a crawler based on Heritrix over the past few days and used mysql to import and export data. When I encountered some garbled code problems, it was hard to solve the problem and record it for viewing.
1. Export data.
First, describe your environment: Mac OS X 10.8.3, MySQL Community Server 5.6.10, and MySQL Workbench 5.2.47.
I want to migrate the data in the local database to another machine, so I used the import/export function in Workbench to call mysqldump. Unfortunately, a version inconsistency error occurs.
If the error persists, find the solution. You can specify the mysql mysqldump path:/usr/local/mysql/bin/mysqldump, this is an insert statement that exports data as an SQL statement.
To export data to excel, use the select statement on the mysql console to export data to an excel file.
The following describes how to export an excel file and how to export it as an insert statement.
1. operate on a terminal.
1 cd /usr/local/mysql/bin/
2. After arriving at the bin directory, you can run the ls-l command to check which programs can be used in the current directory. mysql is used first. The command format is as follows:
Mysql-h Host IP-u username-p Password
For example:
1 ./mysql -hlocalhost -uroot -p123456
Pay attention to the previously added "./".
Then, go to the mysql command console and the terminal displays:
3. Run the show databases command to view all the databases. use the use command to select a database. Note that each command must end with a semicolon.
4. Use SQL statements to export the required data. SQL statements are not limited to queries of a single table. Because my database encoding is in utf8 format, and the default office encoding is gb2312, when a field contains Chinese characters, the Chinese content will be garbled after being exported to excel, in this case, you need to convert the convert encoding. The specific usage is as follows:
I tried to save the file to the desktop, but I always indicated that I didn't have the permission. It should be related to the user. When the path "./" is used for saving, it is actually saved to/usr/local/mysql/data. Open it and check it out. It's not garbled.
For more information, click the next page!
- 2 pages in total:
- Previous Page
- 1
- 2
- Next Page