Mysql 字符集问题2
关键字: mysql 编码
安装后
/etc/init.d/mysql start (stop) 为启动和停止服务器
/etc/mysql/ 主要配置文件所在位置 my.cnf
/var/lib/mysql/ 放置的是数据库表文件夹,这里的mysql相当于windows下mysql的date文件夹
启动mysql后,以root登录mysql
isher@isher-ubuntu:~$ mysql -u root
>show variables like 'character%'; #执行编码显示
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
在某些时候,我们续要修改mysql默认数据库的编码,以保证某些迁移的程序可以正常显示,编辑my.cnf文件进行编码修改,windows可以直接用Mysql Server Instance Config Wizard 进行设置
在linux下修改3个my.cnf的1个/etc/mysql/my.cnf文件
找到客户端配置[client] 在下面添加
default-character-set=utf8 默认字符集为utf8
在找到[mysqld] 添加
default-character-set=utf8 默认字符集为utf8
init_connect='SET NAMES utf8' (设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)
修改好后,重新启动mysql 即可,查询一下show variables like 'character%';
+--------------------------+----------------------------+
| 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/share/mysql/charsets/ |
+--------------------------+----------------------------+
此方法用于标准mysql版本同样有效,对于/etc/my.cnf文件,需要从mysql/support-files的文件夹cp my-large.cnf一份到/etc/my.cnf
Feb 26, 2021 11:50:13 PM
Thanks for sharing this part to the 'Mysql character set problem 2' to learn. As a MySQL learner, diamond purchase online this section is very helpful for me. Great platform to learn. I appreciate the creator of this section.
Jun 20, 2024 05:44:29 AM
I've proper selected to build a blog, which I hold been deficient to do for a during. Acknowledges for this inform, it's really serviceable! Kissimmee Pest Control
Jun 20, 2024 05:49:52 AM
You bear through a awesome vacancy. I sanity definitely quarry it moreover personally suggest to my buddys. I am self-possessed they determination be benefited from this scene. Orlando Pest Control
Jun 20, 2024 05:53:58 AM
Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates. Oviedo Pest Control
Jun 20, 2024 09:34:48 PM
Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. fotograf nunta
Jun 23, 2024 11:57:34 AM
Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. เจลแต้มสิว
Jun 23, 2024 07:11:01 PM
Why do only so much written on this subject? Here you see more. Tampa Pest Control
Jul 31, 2024 04:21:49 PM
I exploit solely premium quality products -- you will observe these individuals on: Yonkers CPA
Aug 28, 2024 08:56:32 PM
You should mainly superior together with well-performing material, which means that see it: اقفال الكويت
Sep 19, 2024 03:07:06 PM
This is helpful, nonetheless it can be crucial so that you can check out the following website: INSTABOOST
Oct 07, 2024 12:45:44 PM
Make the most of mainly premium substances - you will find him or her for: Virtual CPA services for small business