Home > Database > Mysql Tutorial > body text

How to modify mysql default encoding in Ubuntu

WBOY
Release: 2023-06-01 21:58:04
forward
1625 people have browsed it

Modify the mysql configuration file to make the character set settings of the database and server operating system consistent.

vi /etc/my.cnf settings (if this file is not found, create a new one)

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/MySQL/MySQL. Socks

Default character set=utf8 (the key sentence added makes the database store in utf8 by default)

Of course, after modification, the database must be restarted.

Use the mysql -u root -p command again to enter the database system and display the variables like "character_set_%"; the command displays the following content:

- -

| Variable name|value|

- -

| character_set_client | latin1 |

| character _ set _ connection | latin1

|Character set database|utf8

| character _ set _ file system |Binary

| character_set_results | latin1 |

|Character set server|utf8

|Character set system|utf8

| character _ set _ dir |/usr/local/MySQL-5.1.20-beta-Linux-i686- glibc 23/share/MySQL/charset/|

- -

It was found that the key project has used utf8, but this is not enoughIt is also necessary to ensure that the client also uses the utf8 character set To operate .

When logging in, use the following command: MySQL-default-character-set=utf8-u root-p

Use again like "character_set_%" to display variables; command to view the results Becomes:

- -

|Variable name|Value|

- -

| character_set_client | utf8 |

| character _ set _ connection | utf8 |

| character_set_database | utf8 |

| character _ set _ file system |binary

| character_set_results | utf8 |

| character_set_server | utf8 |

| character_set_system | utf8 |

| character _ set _ dir |/usr/local/MySQL-5.1.20-beta-Linux-i686-glibc 23/share/MySQL/charset/|

The above is the detailed content of How to modify mysql default encoding in Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template