Windows系统下配置MySql免安装版

已经安装了Mysql-5.5.25-win32,由于mysql5.6以前版本的InnoDB引擎不支持全文索引FULLTEXT,MYISAM支持全文索引,但是如果既存数据库中表 建立了外键,修改引擎就麻烦了。

本篇介绍Windows7下重新配置免安装版MySql数据库

1.先把原来mysql服务停掉,CMD管理者执行

sc stop mysql

 

2.删除mysql服务,CMD管理者执行

sc delete mysql

 

3.下载mysql5.6包 重新配置或修改环境变量 

MYSQL_HOME = D:\FreeDBS\mysql-5.6.26-winx64    

path += ;%MYSQL_HOME%\bin

 

4.修改mysql.ini

[mysqld]下添加如下

basedir="D:\FreeDBS\mysql-5.6.26-winx64"
datadir="D:\FreeDBS\mysql-5.6.26-winx64\data"
port = 3306
socket = MySQL
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 128K
character-set-server = utf8
server-id = 1

 

[client]下添加如下
port = 3306
socket = MySQL
default-character-set = utf8

 

5.命令注册mysql服务,CMD管理者执行

cd D:\FreeDBS\mysql-5.6.26-winx64\bin

mysqld -install mysql --defaults-file=D:\FreeDBS\mysql-5.6.26-winx64\my.ini

 

6.启动服务,CMD管理者执行

net start mysql

 

7.匿名进入,检验是否安装启动成功。直接输入 mysql

 7.1为root帐户设定密码:

     ①在控制台直接输入 D:\FreeDBS\mysql-5.6.26-winx64\bin>mysqladmin.exe -u root -p password 在这里填入要设定的root密码

     用户名密码登录:mysql -uroot -p新密码

     ②root帐户登录:  mysql -uroot

     设定root帐户密码:set password for root@localhost=password('在这里填入要设定的root密码');

     退出mysql,用户名密码登录:mysql -uroot -p新密码

 7.2修改密码:

      root帐户登录:  mysql -uroot

      UPDATE user SET password=PASSWORD("在这里填入新密码") WHERE user='root'; FLUSH PRIVILEGES;(这个一定要输入)

 

8.添加开发帐户

create user 'username'@'host' identified by 'password';

username – 你将创建的用户名,

host – 指定该用户在哪个主机上可以登陆,如果是本地用户可用localhost.  如果想让该用户可以从任意远程主机登陆,可以使用通配符%. 例: create user 'user'@'%';

password –  该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登 陆服务器.

(删除帐户:DROP USER ‘username’@'host’;)

 

 9.为开发帐户授权

grant privileges on databasename.tablename to 'username'@'host'

privileges – 用户的操作权限,如SELECT, INSERT, UPDATE等.如果要授予所有的权限则使用ALL.

databasename –  数据库名.

tablename-表名,如果要授予该用户对所有数据库和表的相应操作权限则可用 * 表示, 如*.* .

给其他IP地址下的用户授权, 注意必须指定密码, 否则就可以无密码访问

 (撤销用户权限: REVOKE privilege ON databasename.tablename FROM 'username'@'host';)

 

10.刷新数据库:flush privileges;

 

附:MySQL中的操作权限

ALTER
Allows use of ALTER TABLE.

ALTER ROUTINE
Alters or drops stored routines.

CREATE
Allows use of CREATE TABLE.

CREATE ROUTINE
Creates stored routines.

CREATE TEMPORARY TABLE
Allows use of CREATE TEMPORARY TABLE.

CREATE USER
Allows use of CREATE USER, DROP USER, RENAME USER, and REVOKE ALL PRIVILEGES.

CREATE VIEW
Allows use of CREATE VIEW.

DELETE
Allows use of DELETE.

DROP
Allows use of DROP TABLE.

EXECUTE
Allows the user to run stored routines.

FILE
Allows use of SELECT… INTO OUTFILE and LOAD DATA INFILE.

INDEX
Allows use of CREATE INDEX and DROP INDEX.

INSERT
Allows use of INSERT.

LOCK TABLES
Allows use of LOCK TABLES on tables for which the user also has SELECT privileges.

PROCESS
Allows use of SHOW FULL PROCESSLIST.

RELOAD
Allows use of FLUSH.

REPLICATION
Allows the user to ask where slave or master

CLIENT
servers are.

REPLICATION SLAVE
Needed for replication slaves.

SELECT
Allows use of SELECT.

SHOW DATABASES
Allows use of SHOW DATABASES.

SHOW VIEW
Allows use of SHOW CREATE VIEW.

SHUTDOWN
Allows use of mysqladmin shutdown.

SUPER
Allows use of CHANGE MASTER, KILL, PURGE MASTER LOGS, and SET GLOBAL SQL statements. Allows mysqladmin debug command. Allows one extra connection to be made if maximum connections are reached.

UPDATE
Allows use of UPDATE.

USAGE
Allows connection without any specific privileges.

 

reference

posted @ 2015-08-27 15:24  Cyber9527  阅读(127)  评论(0)    收藏  举报