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

Setting of mysql server coding

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article focuses on "mysql server coding settings", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn the "mysql server coding settings"!

After installation, it is found that the server uses lat1 encoding by default after startup.

The specific operation and viewing process are as follows:

Startup method: / etc/init.d/mysql.server start

Effect:

Database changed

Mysql > status

-

Mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86 / 64) using readline 5.1

Connection id: 8

Current database: demodb

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile:''

Using delimiter:

Server version: 5.5.21 MySQL Community Server (GPL)

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: latin1

Db characterset: utf8

Client characterset: latin1

Conn. Characterset: latin1

UNIX socket: / var/lib/mysql/mysql.sock

Uptime: 33 sec

Threads: 7 Questions: 137 Slow queries: 0 Opens: 83 Flush tables: 1 Open tables: 76 Queries per second avg: 4.151

-

Mysql >

Startup method: / etc/init.d/mysql.server start-- character-set-server=utf8

Effect:

Mysql > use demodb

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with-A

Database changed

Mysql > status

-

Mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86 / 64) using readline 5.1

Connection id: 4

Current database: demodb

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile:''

Using delimiter:

Server version: 5.5.21 MySQL Community Server (GPL)

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db characterset: utf8

Client characterset: latin1

Conn. Characterset: latin1

UNIX socket: / var/lib/mysql/mysql.sock

Uptime: 1 min 15 sec

Threads: 4 Questions: 131 Slow queries: 0 Opens: 84 Flush tables: 1 Open tables: 77 Queries per second avg: 1.746

-

Mysql >

In this way, encoding parameters need to be specified each time you start. Otherwise, the server uses the default lat1 encoding of the system.

Another way is to:

Mysql > set character_set_server=utf8

I also tried this method, no, and then log in to the client, and then restore the original coding. The reason is simple: the system does not use utf8 coding when it starts.

The way to do this once and for all is to modify the configuration file.

# vim / etc/my.cnf

The contents are as follows:

[mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

User=mysql

# add the following scarlet letter

Character-set-server=utf8

# Default to using old password format for compatibility with mysql 3.x

# clients (those using the mysqlclient10 compatibility package).

Old_passwords=1

[mysqld_safe]

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

At this point, I believe that everyone on the "mysql server coding settings" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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