Mysql5.7.18 character set configuration, mysql5.7.18 Character Set

Source: Internet
Author: User
Tags mysql command line

Mysql5.7.18 character set configuration, mysql5.7.18 Character Set

 

Background:

A long time ago (, articles were time-sensitive, especially when tools were frequently updated. Remember this time. If there is no value available, refer to the official tool documentation ), I have a new mysql version. The latest version is mysql5.7.18, and the local version is win10 and 64-bit. The general steps are as follows:

1, download: to the official website (https://www.mysql.com) prevail, download response system version;

2. Initialization: run the command line (cmd) to enter the bin folder of the decompressed directory. (Should I decompress the package after downloading it? Too long. There are also files such as the folder "data" and "ini" not downloaded. There are two initialization methods. One is insecure initialization and input: mysqld -- initialize. Initialization causes the root user to have no password (no password, so it is not secure). The other is so-called Secure initialization. input: mysqld -- initialize-insecure: generate the root user with a password. You can view the password in the generated log file, which is in the data file generated after initialization.

 

3. start the service: Enter net start mysql (close the service: Enter net stop mysql). If the prompt net is not an internal command, it may be that net is not installed, or it may be that the environment variable is not configured. Just check it.

4. Basically, this should be the case. Other users can query the mysql command list.

Next, let's talk about how to configure character sets.

Cause:

Yesterday, I first downloaded a Navicat for mysql (Visual Interface) because it was too abstract to view data on the mysql command line.

Then, when inserting data in the table, "Incorrect string value" will be reported. Baidu once said that it wants to change the character set to utf8mb4. This is because other encodings cannot store some special characters. For details, refer to Baidu.

After:

To modify the character set, first go to mysql: mysql-uroot (user logon, because no password is selected for initialization), show variables like 'Char % '(view character encoding ),

You can enter set character_set_server = utf8mb4 in the command line to change the character set. However, the default value is restored only when the service is restarted. Next, let's try other methods. There are different opinions on the Internet, which are vague and difficult to distinguish between true and false. So I went to the official website and looked at it (the official website is also very watery and there are no examples for reference, just like telling the blind man that white is white and I am the blind man ), after reading this document, there is a command for viewing variables: mysqld -- verbose -- help. All the variables you can view can be configured in the option file, each time the service is started, it will be automatically configured in the option file, and the following sentence appears:

Default options are read from the following files in the given order

I think it should be where the option file may exist. That is to say, the new option file should be named after it is displayed and placed in the place where it is displayed.

Create a new my. ini file and place it under D: \ mysql, Which is exactly one of the positions it shows, such. The content of my. ini is as follows:

Basically, it is configured in this form. Here we only use character_set_server, which is the culprit. Of course, the associated character set configurations must be unified. Otherwise, garbled characters may occur, you can go to Baidu to see what each character set means.

Close the mysql service and start the configuration (enter mysqld -- install ):

1. If a non-Administrator opens cmd and enters mysqld -- install, the following message is displayed, indicating that the command is rejected:

2. Open the service as an administrator (delete it first ):

 

3. query mysql service: SC query mysql (you can also find it in Control Panel-management tools-service, or directly search for the Service)

 

4. Delete it: (you can also detach it from the control panel-management tools-service, or directly search for a service)

5. Of course, stop mysql before reinstalling it, even if you delete it first, otherwise:

6. We stopped it. This time it was stopped on the control panel, because it was unloaded before and disappeared after it was stopped (command line: net stop mysql) and re-executed, when the mysql service is successfully started:

7. Restart successfully. log on to the server and check whether the modification is successful:

8. Now, I can try it again several times, as long as I have changed my. after ini, shut down and restart the mysql service, it will press my. i. restart the service after ini.

I want to change it again:

The configuration is here, bye!

 

Related Article

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.