1. 准备文件
mysql 5.5 解压版(绿色版) 下载地址
http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.30-win32.zip (32 bit)
http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.30-winx64.zip (64 bit)
2. 解压到本地目录
D:\devTools\mysql
3. 把MySql添加到系统环境变量
MYSQL_HOME ==> D:\devTools\mysql (新建)
Path ==> ;%MYSQL_HOME%\bin (追加)
4. 修改MySQL5.5的配置文件,把my-small.ini(我用的是my-large.ini)改名为my.ini进行编辑
a). 在[client]下追加
#设置mysql客户端的字符集 default-character-set = utf8
b). 在[mysqld]下追加
#设置mysql的安装目录 basedir = D:\DevTools\mysql #设置mysql数据库的数据存放目录,必须是data或者\xxx-data datadir = D:\DevTools\mysql\data #设置服务器段的字符集 character_set_server = utf8
5. 保存my.ini的配置, 然后打开命令行(开始菜单==>运行==>cmd )
输入: mysqld --console 然后回车将看到如下类似内容:
C:\Users\Lstoryc>mysqld --console 130405 15:22:50 [Note] Plugin 'FEDERATED' is disabled. 130405 15:22:50 InnoDB: The InnoDB memory heap is disabled 130405 15:22:50 InnoDB: Mutexes and rw_locks use Windows interlocked functions 130405 15:22:50 InnoDB: Compressed tables use zlib 1.2.3 130405 15:22:50 InnoDB: Initializing buffer pool, size = 128.0M 130405 15:22:50 InnoDB: Completed initialization of buffer pool 130405 15:22:50 InnoDB: highest supported file format is Barracuda. 130405 15:22:51 InnoDB: Waiting for the background threads to start 130405 15:22:52 InnoDB: 5.5.30 started; log sequence number 2537522 130405 15:22:52 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 130405 15:22:52 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 130405 15:22:52 [Note] Server socket created on IP: '0.0.0.0'. 130405 15:22:52 [Note] Event Scheduler: Loaded 0 events 130405 15:22:52 [Note] mysqld: ready for connections. Version: '5.5.30-log' socket: '' port: 3306 MySQL Community Server (GPL)
==> 证明mysql服务已正常启动
6. 设置登陆mysql root帐号的的密码
打开新的命令行,输入 mysql -uroot 回车
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.30-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
==〉看到上面类似内容说明登陆成功,此时的root帐号是没有密码的
执行命令修改密码:
use mysql;
update user set password=PASSWORD("这里填写你要设置的密码") where user='root';
执行完成后退出mysql操作,然后关闭mysql服务(ctrl+C 关闭另一个命令窗口),然后重启mysql服务