1、通过ssh命令登录linux系统。
2、输入find/-nameserver.xml搜索tomcat的配置文件。
3、通过cd文件路径进入对应的录目位置。
可直接进入 mysql 进行更改,具体如下:1.查找/etc目录下是否有my.cnf文件;
#ls -l | grep my.cnf (在/etc下查找是否有my.cnf文件存在)
2.如果没有就要从/usr/share/mysql,拷贝一个到/etc 下,在/usr/share/mysql目录下有五个后缀为.cnf的文件,分别是 my-huge.cnfmy-innodb-heavy-4G.cnfmy-large.cnf my-medium.cnf my-small.cnf ;从中随便拷贝一个到/etc目录下并将其改为my.cnf文件,我选择的是my-medium.cnf :
#cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
3.修改my.cnf文件,在该文件中的三个地方加上 default-character-set=utf8([client] [mysqld] [mysql])
#vi /etc/my.cnf
修改如下:(红色为添加部分)
[client]
#password = your_password
port= 3306
socket = /var/lib/mysql/mysql.sock
default-character-set=utf8
[mysqld]
port= 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
default-character-set=utf8
init_connect='SET NAMES utf8' //此行可不加
[mysql]
no-auto-rehash
default-character-set=utf8
保存退出;
4.重起MySQL服务器,使其设置的内容生效
#/etc/init.d/mysql restart
5. 重新登入mysql;
# mysql -u root - p
#(输入密码)
mysql>show variables like 'character_set%'
+--------------------------+----------------------------+
| Variable_name| Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |(都生成了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/init.d/mysql [start | stop | restart](实现启动,停止,重启)
也可以通过 #service mysql [start | stop | restart](实现启动,停止,重启)
*********************************
另外:如果在修改字符集前,尝试在数据库中插入中文,那么当修改了字符集后,在你所插入中文的数据库中(在别的数据库中可能没问题),
通过show variables like 'character_set%'查询的结果可如下:
+--------------------------+----------------------------+
| Variable_name| Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results| utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)