首页 > 代码库 > mysql无安装配置

mysql无安装配置

1、Windows7下MySQL5.5.20免安装版的配置

(1)、下载mysql-5.5.20-win32.zip,解压到E:\AppCenter,E盘的AppCenter文件夹下就会出现mysql-5.5.25-winx64目录,将其重命名为mysql。 

(2)、配置MYSQL的环境变量

新建系统变量: MYSQL_HOME,值为E:\AppCenter\mysql
在PATH变量的最后面添加: ;%MYSQL_HOME%\bin

(3)、新建文件my.ini,在my.ini文件中加入如下简单配置:(my.ini是保存在与my-large.ini同一个目录下的)(#表示注释) 

 1 # The following options will be passed to all MySQL clients
 2 [client]
 3 #password   = your_password
 4 port        = 3306
 5   
 6 [mysql]
 7 #设置mysql客户端的字符集
 8 default-character-set = utf8
 9   
10 # The MySQL server
11 [mysqld]  
12 port        = 3306
13 #设置mysql的安装目录
14 basedir = E:\AppCenter\mysql
15 #设置mysql数据库的数据存放目录,必须是data或者\xxx-data
16 datadir = E:\AppCenter\mysql\data
17 #设置服务器段的字符集
18 character_set_server = utf8

(4)、安装mysql为系统服务

用管理员权限运行命令行,执行如下命令:

mysqld --install mysql --defaults-file=E:\AppCenter\mysql\my.ini

(4)、保存后即可用root登进去

1 mysql -uroot -p

回车后会要求输入密码,默认密码为空,直接回车就可以进入mysql的命令行。

(5)、修改root密码

分别执行下面的两条命令(第一个root是密码):

1 update mysql.user set password=password("root") where User="root";
2 flush privileges;

执行的结果如下所示:

1 mysql> update mysql.user set password=password("root") where User="root";
2 Query OK, 3 rows affected (0.00 sec)
3 Rows matched: 3  Changed: 3  Warnings: 0
4 
5 mysql> flush privileges;
6 Query OK, 0 rows affected (0.00 sec)

(6)退出mysql登陆,再次登录输入刚才设计的密码,检验是否能正常使用

 1 mysql> exit;
 2 Bye
 3 
 4 E:\AppCenter\mysql\bin>mysql -uroot -p
 5 Enter password: ****
 6 Welcome to the MySQL monitor.  Commands end with ; or \g.
 7 Your MySQL connection id is 4
 8 Server version: 5.5.25 MySQL Community Server (GPL)
 9 
10 Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
11 
12 Oracle is a registered trademark of Oracle Corporation and/or its
13 affiliates. Other names may be trademarks of their respective
14 owners.
15 
16 Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
17 
18 mysql> show databases;
19 +--------------------+
20 | Database           |
21 +--------------------+
22 | information_schema |
23 | mysql              |
24 | performance_schema |
25 | test               |
26 +--------------------+
27 4 rows in set (0.00 sec)
28 
29 mysql>

 

参考链接:http://supportopensource.iteye.com/blog/1415527