MySQL5.5在Windows下的安装
MySQL 5.5.10 的msi安装总是失败,在实例配置中总是无法通过,这样只能通过Archive进行安装了。
1、首先下载 Windows (x86, 64-bit), ZIP Archive安装包。
2、解压到任意目录如:E:\MySQL\MySQL Server 5.5
3、选择安装目录下的*.ini文件(这里选择my-medium.ini)复制并改名为my.ini文件。添加如下内容:
[client]default-character-set=utf8[mysqld]
basedir="E:/MySQL/MySQL Server 5.5/"
datadir="E:/MySQL/MySQL Server 5.5/data/"character-set-server=utf8
取消如下注释:
innodb_data_home_dir = E:\\MySQL\\MySQL Server 5.5\\data\\
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = E:\\MySQL\\MySQL Server 5.5\\data
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
4、向环境变量Path中添加E:\MySQL\MySQL Server 5.5\bin;
5、测试MySQL是否能正常启动。
c:\>cd e:\mysql\mysql server 5.5\
.\mysqld --console
如果提示:mysqld: ready for connectionsVersion: '5.5.9' socket: '' port: 3306 则表示能正常通过控制台启动MySQL,现在按crtl+c结束,这样就可以断续安装成Windows服务了。
如果有MySQL正在运行,可通过如下命令结束它:
.\mysqladmin -u root shutdown
6、安装Winodws服务。执行如下命令:
.\mysqld.exe --install MySQL5.5 --defaults-file="E:\MySQL\MySQL Server 5.5\my.ini"
net start mysql5.5
7、修改root密码。
首次安装MySQL,用户root并没有设置,这里要为root设置密码:
.\mysql -u root -p
mysql>use mysql;
mysql>desc user;
mysql>GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";//为root添加远程连接的能力。
mysql>update user set Password = password('xxxxxx') where User='root';
mysql>select Host,User,Password from user where User='root';
mysql>flush privileges;
mysql>exit
重新登录MySQL
#.\mysql -u root -p
mysql> show variables like 'char%'; //可查看字符编码是否都设置为utf8
+--------------------------+-------------------------------------------------+
| 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 | E:\MySQL\MySQL Server 5.5\share\charsets\ |
+--------------------------+-------------------------------------------------+
8、添加一个新用户。
grant all privileges on *.* to 用户名0@'%' identified by '密码';
grant all privileges on *.* to 用户名@'localhost' identified by '密码';
grant all privileges on *.* to 用户名@'127.0.0.1' identified by '密码';
#insert into user (Host,User,Password) values('localhost','用户名','密码');
#insert into user (Host,User,Password) values('127.0.0.1','用户名','密码');
insert into user (Host,User,Password) values('::1','用户名','');
#update user set Password = password('密码') where User='用户名';
select Host,User,Password from user where User='用户名';
flush privileges;
注意:grant命令同时会在User表中添加一条新的记录,所以用了grant命令就不需要进行insert in插入新的记录项。
如果想统一该用户所有的密码可使用upadte语句。
9、创建数据库。