Home  >  Article  >  Database  >  Graphic tutorial on installing mysql5.7.18 and changing the initial password

Graphic tutorial on installing mysql5.7.18 and changing the initial password

黄舟
黄舟Original
2017-06-18 10:55:291223browse

这篇文章主要为大家详细介绍了Mysql5.7安装并修改初始密码的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

Centos 安装MySQL可以参考之前写的一篇文章

Centos7.3 安装Mysql5.7并修改初始密码

windows安装mysql5.7有两种方式

1、下载.msi安装文件直接根据界面提示进行安装
2、下载.biz压缩包

这里接介绍的是第二种压缩版的安装方式

1、下载mysql

其他版本下载地址

2、安装mysql

压缩包相当于免安装文件,要想使用它只需要配置相关的参数,再通过通过服务来启动数据库服务就可以了。

2.1 把压缩包解压到你喜欢的位置

本示例解压到:D:\software\mysql-5.7.18-winx64 文件夹下

2.2 创建my.ini文件

mysql-5.7.18-winx64根目录中创建my.ini文件添加以下内容:

[mysqld]
# set basedir to your installation path
basedir=D:\\software\\mysql-5.7.18-winx64
# set datadir to the location of your data directory
datadir=D:\\software\\mysql-5.7.18-winx64\\data
port = 3306
max_allowed_packet = 32M

注意,basedir和datadir是必须要配置的,basedir就是你解压的目录

2.3 配置环境变量

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

2.4 初始化数据库文件

1、以管理员身份运行cmd,进入mysql的bin目录。
2、初始化数据库文件


mysqld --initialize

初始化成功后,会在datadir目录下生成一些文件,其中,xxx.err(xxx是你电脑用户的名称)文件里说明了root账户的临时密码。例子:


2017-05-17T10:31:54.235041Z 1 [Note] A temporary password is generated for root@localhost: <r8j*Qrh)jdp

2.5 注册mysql服务


mysqld -install MySQL

2.6 启动mysql服务


net start MySQL

3、修改root密码

使用root账号登录


mysql -u root -p <r8j*Qrh)jdp

修改root密码


ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;new_password&#39;;

4、安装日志


Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。

D:\software\mysql-5.7.18-winx64\bin>mysqld --initialize

D:\software\mysql-5.7.18-winx64\bin>
D:\software\mysql-5.7.18-winx64\bin>mysqld -install MySQL

D:\software\mysql-5.7.18-winx64\bin>net start MySQL
MySQL 服务正在启动 ....
MySQL 服务已经启动成功。


D:\software\mysql-5.7.18-winx64\bin>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the current input statement.

mysql> ALTER USER &#39;root&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;root&#39;;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye

The above is the detailed content of Graphic tutorial on installing mysql5.7.18 and changing the initial password. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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