Home > Database > Mysql Tutorial > body text

Tutorial on how to install MySQL5.7.18 on Windows

黄舟
Release: 2017-07-18 15:21:31
Original
1318 people have browsed it

这篇文章主要为大家详细介绍了Windows下MySQL5.7.18安装教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文讲解从压缩包安装MySQL。

1.下载MySQL压缩包,【Windows (x86, 64-bit), ZIP Archive】;

2.解压Zip包到需要的目录,例如D:\mysql-5.7.18-winx64;

3.创建my.ini文件,内容如下:


[mysqld] 
port=3306 
basedir=D:\\mysql-5.7.18-winx64\\
datadir=F:\\mysqlData\\
character-set-server=utf8
Copy after login

注意,basedir和datadir是必须要配置的,basedir就是你解压的目录。官方文档上说,如果你喜欢用斜杠,则要用双斜杠,反斜杠的话就不用这样。即:D:\\mysql-5.7.13-winx64\\ 或:D:/mysql-5.7.13-winx64/
由于本人喜欢把数据库的数据文件独立出来,所以就把datadir配置到其它地方,方便管理。

4.配置环境变量

添加一个名叫 MYSQL_HOME 的变量。
修改Path变量,在末尾添加 %MYSQL_HOME%\bin

5.初始化和启动Mysql服务

以管理员权限运行cmd,初始化MySQL,执行


mysqld --initialize-insecure
Copy after login

注册MySQL服务,启动MySQL,执行


mysqld -install
net start mysql
Copy after login

6.登录MySQL,设置root密码


mysql -uroot -p
Copy after login

第一次登录时无需密码直接回车登录,登录mysql之后,设置root密码


ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
Copy after login

修改密码后,我们使用root可登录成功。

The above is the detailed content of Tutorial on how to install MySQL5.7.18 on Windows. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!