MySQL-5.7.11绿色版安装

个人解压缩后目录地址是D:\Program Files\mysql-5.7.11-winx64\,可将此地址替换为你的版本。

一、解压缩后将配置文件my-default.ini复制一份为my.ini,其中内容改成

# For advice on how to change settings please see
http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
 innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
 basedir = "D:\Program Files\mysql-5.7.11-winx64"
 datadir = "D:\Program Files\mysql-5.7.11-winx64\data"
# port = .....
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

二、安装MySQL服务
开始-运行-cmd,cd到mysql安装目录的bin下面,执行“mysqld --install”命令,若是出现 “Install/Remove of the Service Denied! ”错误是权限问题。切换为管理员启动cmd命令,再输入“mysqld --install”,运行成功。



三、启动MySQL服务
直接在cmd中输入命令 “net start mysql”

若是出现“MySQL 服务没法启动”错误,这是5.6.*版本和5.7.*版本的区别 5.6.*版本中相应目录下有*\data文件夹,而5.7.*版本中没有

因此须要输入命令,是用于初始化数据的,初始完后就有data文件夹了。
“mysqld --initialize”这样会生成一个随机的root密码在data文件夹下*.err文件,[Note] A temporary password is generated for root@localhost: 6mQoY:+olm_/
或者  “mysqld  --initialize-inscure” (不设置root密码,建议使用)

若是错误“[ERROR] --initialize specified but the data directory has files in it. Aborting.”将目录底下的data文件夹删除便可。

再输入命令 “net start mysql”,就能够起动。

四、登陆维护MySQL
第一次登录输入命令 “mysql -u root -p",若是要输入密码即上面随机生成的密码“6mQoY:+olm_/”
登陆成功为

退出命令exit;
注意有分号。

五、修改密码
回到bin目录下,输入命令“mysqladmin -u root -p password NewPassword”
上面的“NewPassword”是你要输入的新密码,而后跳出Enter password:以后输入原来随机的密码。
修改密码就成功了。