Mysql Chinese garbled characters and solutions for exporting SQL statements and Excel

Source: Internet
Author: User
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: MacOSX10.8.3, MySQLCommunityServer5.6.10, and MySQLWorkbench5.2.47. I want to set the number of hosts

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 set the number of hosts

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. Run 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.