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

How to solve the problem of garbled code in configuring mysql database under MAC

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

Share

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

This article mainly explains "how to solve the garbled code in the configuration of mysql database under MAC". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to solve the garbled code when configuring the mysql database under MAC"!

Recently, the mac osx lion system was installed, and then the mysql5.5.16 version was installed for development, but as we all know, the default code is latin1. If you store Chinese, there will be garbled codes, and then the problem of google will be crazy, but it has not been solved. Most of the answers on the Internet are as follows:

1. Copy any * .cnf file under / usr/local/mysql/support-files to / etc/my.cnf

two。 Add a sentence default-character-set=utf8 (or default_character_set=utf8) after [mysqld] and [client] in the my.cnf file

3. Save exit

4. Just restart the mysql server.

However, I have tried many times, and after this modification, the mysql service will not start at all.

By chance, I found a way to configure the coding problem of mysql under linux. With a try, I modified it and found that it really works, so I hope that friends who pretend to be Mac don't have to take detours any more. The configuration method is as follows:

1. Copy any * .cnf file under / usr/local/mysql/support-files to / etc/my.cnf

two。 Add a default-character-set=utf8 (not default_character_set= UTF8 [I] [/ I]) after [client] in the my.cnf file. I have not tried this configuration, and I don't know if it will succeed. The key lies in the configuration here. Add the following three sentences after [mysqld]:

Default-storage-engine=INNODB

Character-set-server=utf8

Collation-server=utf8_general_ci

3. Save exit

4. Just restart the mysql server.

Then check the code in the mysql database and find that it has been changed to utf8.

Here are the results I found when I restarted the mysql server and entered the mysql database:

Java code

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 520

Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql > show variables like'% char%'

+-+

| | Variable_name | Value |

+-+

| | character_set_client | utf8 |

| | character_set_connection | utf8 |

| | character_set_database | utf8 |

| | character_set_filesystem | binary |

| | character_set_results | utf8 |

| | character_set_server | utf8 |

| | character_set_system | utf8 |

| | character_sets_dir | / usr/local/mysql-5.5.16-osx10.6-x86_64/share/charsets/ |

+-+

8 rows in set (0.00 sec)

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 520

Server version: 5.5.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql > show variables like'% char%'

+-+

| | Variable_name | Value |

+-+

| | character_set_client | utf8 |

| | character_set_connection | utf8 |

| | character_set_database | utf8 |

| | character_set_filesystem | binary |

| | character_set_results | utf8 |

| | character_set_server | utf8 |

| | character_set_system | utf8 |

| | character_sets_dir | / usr/local/mysql-5.5.16-osx10.6-x86_64/share/charsets/ |

+-+

8 rows in set (0.00 sec)

At this point, the problem that has plagued us for many days has finally been solved.

The contents of the modified my.cnf file are attached. I don't know why I can't upload the attachment, so post the code:

Java code

# Example MySQL config file for small systems.

#

# This is for a system with little memory (

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

Wechat

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

12
Report