(1)修改 MySql安装目录下面的my.ini(MySQL Server Instance Configuration 文件)。 设置
default-character-set=gbk(注意,有2处)
(2)修改data目录中相应数据库目录下的db.opt配置文件
default-character-set=gbk
default-collation=gbk_chinese_ci
重启数据库,关闭控制台窗口重新登录数据库,执行SQL,一切正常
can't obtain database list from the server
access denied for user 'root' @ localhost
.Windows环境下:
1. 管理员登陆系统,停止mysql服务或者结束mysqld-nt进程
2. 进入命令行,来到mysql的安装目录.假设安装目录为 d://mysql// , CMD进入命令行
3. 运行 d://mysql//bin//mysqld-nt --skip-grant-tables 启动mysql,关闭权限的检查
4. 运行 d://mysql//bin//mysqladmin -u root flush-privileges password "newpassword" 重设root密码
5. 重新启动mysql服务
update user set password=password("newpassword") where host="localhost" and user="root";
E:/MySQL Server 5.0/bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 4
Server version: 5.0.46-enterprise-gpl-nt MySQL Enterprise Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> use mysql;
Database changed
mysql> update user set password=password("password") where host="localhost" and
user="root";
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
E:/MySQL Server 5.0/bin>