我是靠谱客的博主 危机早晨,这篇文章主要介绍Windows Server 2008完美安装MySQL Community Server 5.7.16六步曲 0.下载安装介质 1.解压缩 2.设置系统环境变量 3.创建my.ini 文件和data目录,配置安装路径与数据存储路径 4.安装MySQL服务 5.启动MySQL服务 6.修改root密码 ,现在分享给大家,希望可以做个参考。

    今天在Windows Server 2008 r2系统下部署了 MySQL Community Server 5.7.16,安装过程中也遇到了一些问题,在这儿记录一下最终的安装过程。

0.下载安装介质

   我们可以登录MySQL官网来下载安装介质,网址是: http://dev.mysql.com/downloads/。我选择的是64位压缩包版本“ Windows (x86, 64-bit), ZIP Archive”。


1.解压缩

将下载到本地的安装介质解压缩。然后,将解压后的文件夹mysql-5.7.16-winx64拷贝到安装目录(E盘根目录)下。

2.设置系统环境变量

右键点击 计算机>>属性>> 高级系统属性>>环境变量>> 编辑 Path ,在最后添加” ;E:mysql-5.7.16-winx64bin“,确定。

3.创建my.ini 文件和data目录,配置安装路径与数据存储路径

在 E:mysql-5.7.16-winx64目录下创建data目录和my.ini,并在my.ini中配置 安装路径与数据存储路径等信息。

点击(此处)折叠或打开

  1. [mysql]
  2. default-character-set=utf8
  3. [mysqld]
  4. max_connections=200
  5. default-storage-engine=INNODB
  6. basedir =E:mysql-5.7.16-winx64bin
  7. datadir =E:mysql-5.7.16-winx64data
  8. port = 3306

4.安装MySQL服务

首先,以管理员身份运行 cmd 并切换到MySQL的bin目录下;

接下来,执行mysqld --initialize-insecure

    这条命令用来初始化data文件,其中insecure选项指定登录无需口令。

点击(此处)折叠或打开

  1. D:>e:
  2. E:>cd mysql-5.7.16-winx64
  3. E:mysql-5.7.16-winx64>cd bin
  4. E:mysql-5.7.16-winx64bin>mysqld --initialize-insecure
  5. E:mysql-5.7.16-winx64bin>
需要注意的是,如果不指定insecure选项,则会随机生成登陆密码, 在E:mysql-5.7.16-winx64data文件夹下,有一个 hoegh.err 文件,其中hoegh是主机名,打开会看到:
2016-10-20T09:34:56.806257Z 1 [Note] A temporary password is generated for root@localhost: p-mcI:ijR6Xg,
其中  p-mcI: ijR6Xg即为随机密码。

然后,输入 mysqld --install安装MySQL服务

我们会看到界面出现:Server successfully installed,这就说明 MySQL服务安装成功。 

点击(此处)折叠或打开

  1. E:mysql-5.7.16-winx64bin>
  2. E:mysql-5.7.16-winx64bin>mysqld --install
  3. Service successfully installed.
  4. E:mysql-5.7.16-winx64bin>

5.启动MySQL服务

输入  net start mysql  回车, 就会看到: MySQL 服务已经启动成功。尝试使用root用户登录数据库,并通过show databases命令查看数据库概要信息。

点击(此处)折叠或打开

  1. E:mysql-5.7.16-winx64bin>
  2. E:mysql-5.7.16-winx64bin>net start mysql
  3. MySQL 服务正在启动 .
  4. MySQL 服务已经启动成功。


  5. E:mysql-5.7.16-winx64bin>mysql -u root
  6. Welcome to the MySQL monitor. Commands end with ; or g.
  7. Your MySQL connection id is 2
  8. Server version: 5.7.16 MySQL Community Server (GPL)

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

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

  13. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

  14. mysql> show databases;
  15. +--------------------+
  16. | Database |
  17. +--------------------+
  18. | information_schema |
  19. | mysql |
  20. | performance_schema |
  21. | sys |
  22. +--------------------+
  23. 4 rows in set (0.00 sec)

  24. mysql>

6.修改root密码

    安全起见,我们修改一下root密码。

点击(此处)折叠或打开

  1. mysql>
  2. mysql> alter user 'root'@'localhost' identified by 'root';
  3. Query OK, 0 rows affected (0.00 sec)

  4. mysql>
  5. mysql> exit
  6. Bye

  7. E:mysql-5.7.16-winx64bin>mysql -u root -proot
  8. mysql: [Warning] Using a password on the command line interface can be insecure.
  9. Welcome to the MySQL monitor. Commands end with ; or g.
  10. Your MySQL connection id is 4
  11. Server version: 5.7.16 MySQL Community Server (GPL)

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

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

  16. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

  17. mysql> show databases;
  18. +--------------------+
  19. | Database |
  20. +--------------------+
  21. | information_schema |
  22. | mysql |
  23. | performance_schema |
  24. | sys |
  25. +--------------------+
  26. 4 rows in set (0.00 sec)

  27. mysql>


~~~~~~~ the end~~~~~~~~~
hoegh
2016.10.20

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30162081/viewspace-2126797/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30162081/viewspace-2126797/

最后

以上就是危机早晨最近收集整理的关于Windows Server 2008完美安装MySQL Community Server 5.7.16六步曲 0.下载安装介质 1.解压缩 2.设置系统环境变量 3.创建my.ini 文件和data目录,配置安装路径与数据存储路径 4.安装MySQL服务 5.启动MySQL服务 6.修改root密码 的全部内容,更多相关Windows内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(109)

评论列表共有 0 条评论

立即
投稿
返回
顶部