出现网页显示乱码,但是在数据库中却正常显示的问题
更改Mysql安装目录下的my.ini文件内
[client]
port=3306
[mysql]
default-character-set=gbk
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.5/"
#Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
里面有两个character-set-server,上面的改成gbk,下面改成utf8
然后输入net stop mysql ,停止MySQL
再重新启动MySQL,net start mysql
最后再将数据库删掉重新建表输入