win7 32位系统使用mysql 无法登录数据库 提示mysql: unknown variable 'character-set-server=utf8'

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了win7 32位系统使用mysql 无法登录数据库 提示mysql: unknown variable 'character-set-server=utf8'相关的知识,希望对你有一定的参考价值。

我使用mysql-5.6.13-win32.zip 安装
mysqld.exe --install mysqlserver --defaults-file=D:/AppS/mysql-5.6.13-win32/my.cnf
装完后,服务可以正常启动,但在使用mysql.exe -u root -p 连接数据库的时候提示
mysql: unknown variable 'character-set-server=utf8'
不知道什么原因
下面的是我的my.cnf 配置文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
character-set-server=gbk
[mysqld]
basedir =D:/AppS/mysql-5.6.13-win32
datadir =D:/AppS/mysql-5.6.13-win32/data
character-set-server=gbk
port=3306

[mysql]
default-character-set=gbk

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

参考技术A 用这个试一试

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[client]
default-character-set=gbk
#default-character-set=utf8

[mysqld_safe]
default-character-set=gbk
#default-character-set=utf8

[mysqld]
#default-character-set=gbk
#default-character-set=utf8

init_connect='SET NAMES gbk'
#init_connect='SET NAMES utf8'

character_set_server=gbk
#character_set_server=utf8
lower_case_table_names=0
#character_set_client=utf8
character_set_client=gbk

#init_connect='SET collation_connection=gbk_chinese_ci'
#init_connect='SET NAMES gbk'
#character-set-server=gbk
#collation-server=gbk_chinese_ci
skip-character-set-client-handshake

#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

#sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysql]
default-character-set=gbk

#sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

#sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

#sql_mode=STRICT_TRANS_TABLES
参考技术B gbk改成utf8追问

试过了,还是一样的,没用。

追答

好吧,那我也不晓得了,我用也是win7 32的,只改了字符集。貌似只要安装好了就能登陆的,你确定你的mySQL安装好了?有一个英文安装和一个中文哦,先装英文的,后装中文的,装完就能登陆

参考技术C 问题出在两个地方:
第一、
[client]
character-set-server=gbk
在【client】节点下配置的内容都是用于mysql客户端的,所以肯定不会有server端的选项啊。
第二、在【mysql】节下面多了
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
这句配置。这句配置应该是放在【mysqld】节下的。如果有这个节就把上面那句剪切到mysqld下,否则,删除那一句。
把你的my.cnf换成下面的样子试试:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
#character-set-server=gbk
default-character-set=gbk
[mysqld]
basedir =D:/AppS/mysql-5.6.13-win32
datadir =D:/AppS/mysql-5.6.13-win32/data
character-set-server=gbk
port=3306

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
default-character-set=gbk

再试试看
参考技术D 虽然年头久了,不过还是回答一下
题主你的配置文件里应该出现了两句sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

不要问我为什么知道

如何获取当前登录电脑的windows账户信息

参考技术A 按【Win + R】快捷键,在弹出的运行对话框中输入【cmd】后按回车键,如下图所示:

这里有两条命令都可以查询当前用户的SID。
第一条指令:【whoami /user】
在命令提示符窗口中输入"whoami /user",按回车键,如下图所示:

下图就是我当前的用户名和对应的SID,这和上图注册表图片中的一项是一样的,如下图所示:

4
第二条指令:【wmic useraccount get name,sid】
在命令提示符窗口中输入"wmic useraccount get name,sid",按回车键,如下图所示:

5
下图就是这条指令的执行结果,连其他两个用户的用户名也查出来了,如下图所示:

以上是关于win7 32位系统使用mysql 无法登录数据库 提示mysql: unknown variable 'character-set-server=utf8'的主要内容,如果未能解决你的问题,请参考以下文章

64位win7系统如何安装MySQL

(32位)WIN7系统下安装SQL2000企业版,桌面右下角的服务无显示打开,金蝶K3中间层无法启动。如何解决??

win7旗舰版32位电脑突然多出piress账户,查资料说是mysql漏洞导致黑客攻击,怎么删除

求32位win 7系统Intel HD Graphics 630显卡驱动

Win7怎么设置多用户同时远程登录

新建虚拟机_WIN7 32位系统