在Windows下安装mysql,注意自己的Windows是32位还是64位。
MySQL官网下载地址:https://dev.mysql.com/downloads/mysql/

下载完之后,解压放到自己需要的位置,例如:D:\MySQL\mysql-8.0.11-winx64
接下来就可以配置环境变量了
变量名:MYSQL_HOME
变量值:D:\MySQL\mysql-8.0.11-winx64
path里添加:%MYSQL_HOME%\bin
使用cmd,记住需要用管理员启动cmd,不然不会成功的,如果不知道怎么用管理员权限启动cmd,可以通过C:\Windows\System32 下的cmd.exe


切换到你安装mysql的目录\bin下面

执行命令:mysqld -install

这里我的出现了问题

出现上面问题的原因是它初始化的路径和我现在安装的路径不同,以前安装的MySQL的一些配置没有删除干净。
起初我没有细看,接着执行了net start mysql启动MySQL服务,报错

解决:卸载移除:mysqld --remove

接着执行命令:mysqld -install ,这回就没有问题了

最后启动服务net start mysql

接下来测试一下MySQL是否可以正常使用,登陆MySQL,因为没有设置密码,所以密码直接回车就可以了 mysql -u root -p ,root是默认的用户。

测试一下查询用户名和密码:select host,user,authentication_string from mysql.user;

mysql安装完毕。
|