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

本文提供了一个详细的指南,指导用户在Windows环境中安装和配置MySQL数据库版本5.7.11。包括下载、解压、初始化、启动、登录及设置密码等关键步骤,并介绍了系统环境变量的设置方法。此外,文章还提供了官方文档链接以供深入学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先,到官网里下载相应的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 ! Please consider 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 as root using the random password that the server generated during the initialization sequence:

      shell> mysql -u root -p
      Enter 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 as root 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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值