这两天在用mysql,刚好也碰到了这个问题,此方法可行,特记录之。
本文转自:http://hi.baidu.com/hiran/blog/item/5c5ab309ae841ac53ac7634c.html
MySql-noinstall (绿色)解压版WINDWOS下安装[附:XP下1067错误解决方案]
1.下载mysql-noinstall-5.1.39-win32.zip,解压到D盘,重命名为 mysql(D:\mysql)。
2.复制my-medium.ini为my.ini。
3.修改my.ini,在[client]、[mysqld]、[mysql]后面加default-character-set = utf8,在[mysqld]下加,basedir、datadir。
[client]
default-character-set = utf8
[mysqld]
default-character-set = utf8
default-collation=utf8_bin
init_connect='SET NAMES utf8'
basedir=D:\mysql\
datadir=D:\mysql\data\
[mysql]
default-character-set=utf8
4.安装mysql服务。(移除mysql服务mysqld --remove)
命令行下进入D:\mysql\bin,运行mysqld --install mysql --defaults-file="D:\mysql\my.ini"。
D:\mysql\bin>mysqld --install mysql --defaults-file="D:\mysql\my.ini"
Service successfully installed.
注:要加参数安装,不然mysql administrator启动时将提示:
Either the server service or the configuration file could not be found.Startup variable and service section are there for disabled.
进入后提示:
This section is only avaliable when connected to localhost
5.启动mysql服务.(停止mysql服务net stop mysql)
D:\mysql\bin>net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。
6.进入mysql,并给MYSQL的root用户加密码。
D:\mysql\bin>mysql -uroot -p
Enter password:
此时密码为空,提示输入密码,直接回车。
D:\mysql\bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.39-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; #显示所有数据库
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)
mysql> use mysql; #切换进mysql数据库
Database changed
mysql> show tables;#显示mysql数据库中所有表。
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
| user_info |
+---------------------------+
24 rows in set (0.09 sec)
mysql> #更新mysql数据库中,user表中的root用户密码为aran;
mysql> update user set password=PASSWORD("aran") where User='root';
Query OK, 0 rows affected (0.06 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges;#更新MySQL的权限表,使刚才的密码更改生效.也可以重启mysql服务.
Query OK, 0 rows affected (0.02 sec)
mysql> exit;#退出
Bye
D:\mysql\bin>mysql -uroot -p #用新密码登陆,成功
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.39-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> status; #查看mysql状态.显示第三步设置的字符集已经生效.
--------------
mysql Ver 14.14 Distrib 5.1.39, for Win32 (ia32)
Connection id: 2
SSL: Not in use
Using delimiter: ;
Server version: 5.1.39-community-log MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Client characterset: utf8
Server characterset: utf8
TCP port: 3306
Uptime: 21 min 5 sec
Threads: 1 Questions: 19 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.15
--------------
mysql> SHOW VARIABLES LIKE 'character_set_%'; #查看mysql状态.显示第三步设置的字符集已经生效.
+--------------------------+--------------------------+
| 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 | utf8 |
| character_set_system | utf8 |
| character_sets_dir | D:\mysql\share\charsets\ |
+--------------------------+--------------------------+
8 rows in set (0.02 sec)
mysql> SHOW VARIABLES LIKE 'collation_%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
mysql>
重要:在xp下,第四步安装,提示成功后,第五步启动mysql服务时,将出现1067错 误,如下:
D:\mysql\bin>net start mysql
mysql 服务正在启动 ..
mysql 服务无法启动。
系统出错。
发生系统错误 1067。
进程意外终止。
在网上没找到解决方案,我的解决方案如下:
1.开始>运行>services.msc
2.查看mysql服务的可执行文件的路径为:D:\mysql\bin\mysqld D:\mysql\my.ini mysql
问题就出现在这,明显,mysqld安装时,启动属性丢失。
这应该是mysql在xp下的bug,在2003下没这样的问题。
3.解决方案,把下面的代码存成m.inf,放在mysql目录下。
[Version]
Signature="$WINDOWS NT$"
[DefaultInstall.Services]
AddService=mysql,,My_AddService_Name
[My_AddService_Name]
DisplayName=mysql
Description=mysql-noinstall-5.1.39-win32
ServiceType=0x10
StartType=2
ErrorControl=0
ServiceBinary=D:\mysql\bin\mysqld.exe --defaults-file="D:\mysql\my.ini" MySQL
4.重装mysql服务,之前先移除刚装的mysql服务,用rundll32.exe注册刚才的文件。
D:\mysql\bin>mysqld --install mysql --defaults-file="D:\mysql\my.ini"
Service successfully installed.
D:\mysql\bin>mysqld --remove
Service successfully removed.
D:\mysql\bin>rundll32.exe setupapi,InstallHinfSection DefaultInstall 128 d:\mysql\m.inf
D:\mysql\bin>
4.启动mysql 服务.
D:\mysql\bin>net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。
--转自