时间:2021-07-01 10:21:17 帮助过:33人阅读
mysql> set names utf8; Query OK, 0 rows affected (0.00 sec)
8 查看是否成功修改了
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 | gbk | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec) 9 再次查询表luzhi的数据,发现可以正常显示 mysql> select * from luzhi; +------+---------+ | id | name | +------+---------+ | 2 | 你好 | | 4 | 甪直 | +------+---------+ 4 rows in set (0.01 sec)
10 上面的方法只是临时的更改,当退出mysql再次进入的就会失效了。
永久更改:
#vim /etc/my.cnf [client] #password = your_password port = 3306 socket = /var/lib/mysql/mysql.sock default-character-set=gbk #这里可以设置你所需要定义的编码 utf8 # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /var/lib/mysql/mysql.sock datadir = /home/rzrk/mysql 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=gbk #这里可以设置你所需要定义的编码 utf8
修改完成后必须重启mysql才能生效
#service mysql restart #mysql uroot -p > show variables like "character%";
本文出自 “天道酬勤” 博客,请务必保留此出处http://luzhi1024.blog.51cto.com/8845546/1651596
解决mysql中无法显示中文的一个实例
标签:version current tables 数据库 mysql utf8