mysql乱码
进入mysql:
mysql -u 用户名 -p
然后输入密码
查看数据库的编码方式:
status;
主要看这4个:
Server characterset: latin1 Db characterset: utf8 Client characterset: latin1 Conn. characterset: latin1
如果要修改为utf-8的,修改/etc/my.cnf文件
在[client]下追加:
default-character-set=utf8
在[mysqld]下追加:
character-set-server=utf8
在[mysql]下追加:
default-character-set=utf8
然后保存并退出。
重启mysqld即可:
service mysqld restart
再查看编码方式:
mysql> status; -------------- mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1 Connection id: 36 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.1.73 Source distribution Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 1 hour 15 sec
完成