Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of MySql5.7.18 character set configuration

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the MySql5.7.18 character set configuration method, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Background of the story:

A long time ago (2017.6.5, the article has its timeliness, especially the tools used are updated frequently, please remember this time, if it is no longer valuable, everything is subject to the official documentation of the tool), the next mysql version to play, happens to be the latest mysql5.7.18, native is win10, 64-bit system. The steps are roughly as follows:

1. Download: based on the official website (https://www.mysql.com), the download response system version

2. Initialization: the command line (cmd) enters the unzipped directory bin folder (it should be unzipped after download, right? It's been too long. I kind of forgot. And there are no files such as data folder and ini when downloaded. There are two initialization methods. One is called insecure initialization, and input: mysqld-- initialize, initialization makes the root user without a password (no password, so it is not secure); one is the so-called security initialization, enter: mysqld-- initialize-insecure to generate a root user with a password, the password can be checked in the log file that appears after generation, just in the data file generated after initialization

3. Start the service: enter: net start mysql (shutdown service: enter: net stop mysql). If you prompt that net is not an internal command, then either net is not installed or the environment variable is not configured. Just check it.

4. Basically, it should be like this. Others can consult the mysql command to do it.

Let's talk about the problem of configuring character sets.

Cause:

Just yesterday, it was too abstract to view the data on the mysql command line first, so I downloaded a Navicat for mysql (visual interface) first, and it looked much better. As shown in the figure:

Then insert data in the table will report an error "Incorrect string value", Baidu said to change the character set to utf8mb4, this is because other codes can not store some special characters, details can be Baidu.

After:

To modify the character set, first enter mysql: mysql-uroot (user login because the one without password is selected for initialization) and show variables like 'char%' (check character encoding), as shown in the figure:

You can change the character set by typing set character_set_server=utf8mb4 on the command line, but it is valid only for this time. The default value will be restored when the service is restarted. Next try other methods, online opinions vary, ambiguous, it is difficult to distinguish between true and false. So I went to the official website to have a look (the official website is also very watery, and there are no examples to refer to, just like telling the blind man that white is white, and I am the blind man). There is an instruction in the document to view variables: mysqld-- verbose-- help. The variables can be configured in the options file. Every time you start the service, you will automatically configure it according to the options file, and then a sentence appears here:

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 the name it shows and put it where it should be. As shown in the figure:

Create a new my.ini file and place it under D:\ mysql, which is exactly one of the locations it shows, as shown above. The my.ini content is as follows:

Basically, it is matched in this form. Here is only the culprit character_set_server. Of course, the configuration of the associated character set should be unified, otherwise there may be garbled codes. You can go to Baidu to see what each character set represents.

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

1. If a non-administrator opens cmd and enters mysqld-- install will report the following information, saying that the command has been rejected:

2. Use the administrator to open it and say that the service already exists (then delete it first):

3. Query mysql services: sc query mysql (can also be found in Control Panel-Management tools-Services, or search services directly)

4. Delete it: (you can also uninstall it in Control Panel-manage tools-Services, or search for services directly)

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

6. We stopped it, this time in the control panel, because it was uninstalled before, then disappeared (command line: net stop mysql), re-executed, and successfully started the mysql service at the same time:

7. Restart successfully. Log on to see if any changes are successful:

8. Then you can do it here, and then try it several times. As long as you change the my.ini, shut down and restart the mysql service, it will be changed by my.ini every time. In other words, if you are not satisfied with it in the future, you just need to change the my.ini and restart the service. As shown in the figure:

I'll change it again:

Thank you for reading this article carefully. I hope the article "the method of MySql5.7.18 character set configuration" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report