Windows10中安装mysql5.7.11 社区版64位

来源:互联网 发布:json decode null 编辑:程序博客网 时间:2024/06/02 21:06

首先,到官网里下载相应的zip包:

http://dev.mysql.com/downloads/mysql/


下载完成后解压到目标安装路径,比如说,D:\Program Files

mysql 5.7.11跟5.6的不一样在于其压缩包里面默认是没有data目录的,所以,解压缩后要进行某些初始化工作。


以管理员的权限打开cmd,快捷键Win+x,然后按a,确定即可打开具备管理员权限的cmd窗口。

切换到mysql的bin目录下输入mysqld --initialize-insecure:


这里为什么要用--initialize-insecure呢?

官网里有这么一段话描述:

To initialize the data directory, invoke mysqld with the --initialize or --initialize-insecure option, depending on whether you want the server to generate a random initial password for the'root'@'localhost' account.

...

  1. The server creates a 'root'@'localhost' superuser account. The server's action with respect to a password for this account depends on how you invoke it:

    • With --initialize but not --initialize-insecure, the server generates a random password, marks it as expired, and writes a message displaying the password:

      [Warning] A temporary password is generated for root@localhost:iTag*AfrH5ej
    • With --initialize-insecure, (either with or without --initialize because --initialize-insecure implies --initialize), the server does not generate a password or mark it expired, and writes a warning message:

      Warning] root@localhost is created with an empty password ! Pleaseconsider switching off the --initialize-insecure option.
  1. Connect to the server:

    • If you used --initialize but not --initialize-insecure to initialize the data directory, connect to the server asroot using the random password that the server generated during the initialization sequence:

      shell> mysql -u root -pEnter password: (enter the random root password here)

      Look in the server error log if you do not know this password.

    • If you used --initialize-insecure to initialize the data directory, connect to the server asroot without a password:

      shell> mysql -u root --skip-password 

大意是说,如果使用--initialize参数初始化的话,则系统会产生一个随机的密码,而mysql默认的输出是不显示在控制台里的,所以我们会不知晓密码是什么。如果想用--initialize参数,则添加--console参数让输出导向到控制台里,则系统产生的随机密码便可以得到


接下来就启动并mysql:



启动mysql用的命令是

net start mysql

登录mysql用的命令是

mysql -u root --skip-password

登陆完毕后记得重设root用户密码,输入命令

ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';


执行命令成功则显示Query OK。

输入 exit; 退出mysql:




接下来就是设置系统环境变量,添加mysql的bin目录到path上,过程就不详述了。

然后在path路径上添加

;%MYSQL_HOME%

注意前边有个      ;    


至此,mysql已安装好。


此教程没有附上设置系统启动的,具体如何操作可以参考如下的官方文档:

官方参考文档地址:

http://dev.mysql.com/doc/refman/5.7/en/windows-installation.html


0 0