• 已删除用户
Administrator
发布于 2018-01-07 / 24 阅读
1

Windows10上安装离线版mysql 8.0.3,设置密码,修改密码

    现在的mysql都是安装到C盘里,没有选择,对于C盘空间不多的人情况非常糟糕,所以在这里记录一下本人的安装离线版本经历,Windows10上安装离线版mysql 8.0.3步骤如下:

1、下载离线安装包并配置my.ini

   下载离线安装包并解压到一个目录


    D:\MYSQL\mysql-8.0.3-rc-winx64


    


    在此目录下新建一个文件名为my.ini的文件,内容如下:
   

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=D:\MYSQL\mysql-8.0.3-rc-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\MYSQL\mysql-8.0.3-rc-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

  其中basedir为mysql的安装目录,请根据你的实际情况填写:basedir=D:\MYSQL\mysql-8.0.3-rc-winx64
  其中datadir为mysql数据库的数据的存放目录,请根据你的实际情况填写:datadir=D:\MYSQL\mysql-8.0.3-rc-winx64\data 注:这个目录一定是空目录或不存在

2、设置系统环境变量

    把mysql目录的bin目录添加到系统环境变量的Path中,请求根据实际情况填写,本人路径如下:
    D:\MYSQL\mysql-8.0.3-rc-winx64\bin
    

3、初始化mysql

    用管理员权限打开dos(命令提示符),进入:
    

D:
cd D:\MYSQL\mysql-8.0.3-rc-winx64\bin


    这里有两种情况:
    1)不需要密码情况,执行命令:
         

mysqld --initialize-insecure

   此时用户名为:root,密码为空

    2)设置密码情况,执行命令:
    

mysqld --initialize

  此时用户名为:root,密码在data目录下的“电脑名称.err”文件中,如要本当前文件名为:Rich.err,打开此文件找到密码:如下:
  

2018-01-07T06:12:38.151918Z 0 [Note] Basedir set to D:\MYSQL\mysql-8.0.3-rc-winx64\
2018-01-07T06:12:38.161659Z 0 [Warning] You need to use --log-bin to make --log-slave-updates work.
2018-01-07T06:12:41.536260Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c4b8535a-f371-11e7-91b5-00ff5d5a956e.
2018-01-07T06:12:41.545595Z 0 [Warning] You have not provided a mandatory server-id. Servers in a replication topology must have unique server-ids. Please refer to the proper server start-up parameters documentation.
2018-01-07T06:12:41.552998Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-01-07T06:12:41.563657Z 5 [Note] A temporary password is generated for root@localhost: nsNrj8avKP&D

A temporary password is generated for root@localhost: nsNrj8avKP&D

这一行就是密码:nsNrj8avKP&D

4、安装mysql

     执行如下命令:

mysqld install

   提示:Service successfully installed.安装成功

5、启动Mysql

   执行如下命令:

net start mysql

  启动成功后连接测试,执行如下命令:

  

mysql -uroot -p

   输入密码 nsNrj8avKP&D 连接成功,如下
   

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.3-rc-log

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 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

  到这里mysql安装全部完成

 

  附:

   修改密码命令,执行下如命令:

mysqladmin -uroot -p password 123456

  输入旧密码,新密码修改为123456