您的位置:首页 > 数据库 > MySQL

mysql安装详细指南

2016-08-14 02:52 591 查看
1.下载安装包mysql-5.7.14-win32.msi

2.安装MySQL,我安装在D:\MySQL\MySQL Server 5.7目录下

3.将目录下的默认文件 my-default.ini 改名 为my.ini

4.打开my.ini,添加配置:

    [WinMySQLAdmin]

    Server=D:\MySQL\MySQL Server 5.7\bin\mysqld.exe

    [mysqld]

    basedir = D:\MySQL\MySQL Server 5.7

    datadir = D:\MySQL\MySQL Server 5.7\data

    port = 3306

    server_id = 1

    max_connections=1024

    log_bin = mysql-bin

    explicit_defaults_for_timestamp = TRUE

    sql_mode=ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,

           ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES

5.在D:\MySQL\MySQL Server 5.7目录下创建data文件夹用来存放数据

6.我的电脑->属性->高级系统设置(高级)->环境变量,

    添加MYSQL_HOME变量,值为D:\MySQL\MySQL Server 5.7

    在Path变量中添加%MYSQL_HOME%\bin用分号(;)隔开

7.cmd进入到bin下输入初始化命令(管理员方式打开cmd):

    D:\MySQL\MySQL Server 5.7\bin>mysqld --initialize --user=mysql --console

   2016-08-07T02:57:11.678911Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.

2016-08-07T02:57:11.678911Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.

2016-08-07T02:57:16.351247Z 0 [Warning] InnoDB: New log files created, LSN=45790

2016-08-07T02:57:17.335589Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2016-08-07T02:57:18.054363Z 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: a700687c-5c4a-11e6-830e-e89a8ffd15e0.

2016-08-07T02:57:18.132545Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2016-08-07T02:57:18.210786Z 1 [Note] A temporary password is generated for root@localhost: dei05oKloX)k

   此时产生一个随机密码请记住:dei05oKloX)k

   如果出现如下告警,:

          2016-08-07T02:19:28.889373Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

   检查你的my.ini 中explicit_defaults_for_timestamp = TRUE是否配置正确

          2016-08-07T02:19:28.904984Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.

   这是前面安装失败导致D:\MySQL\MySQL Server 5.7\data下产生了旧数据,将旧数据删掉。

8.cmd进入bin输入安装命令:

           D:\MySQL\MySQL Server 5.7\bin>mysqld --install

           Service successfully installed.

   表示安装成功

9.cmd进入bin输入启动命令:

           D:\MySQL\MySQL Server 5.7\bin>net start MySQL

           MySQL 服务正在启动 ..

           MySQL 服务已经启动成功。

10.cmd进入bin输入进入mysql命令:

           D:\MySQL\MySQL Server 5.7\bin>mysql -u root -p

           Enter password:输入第7步产生的随机密码

           Welcome to the MySQL monitor.  Commands end with ; or \g.

           Your MySQL connection id is 3

           Server version: 5.7.14-log

           Copyright (c) 2000, 2016, 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>表示成功进入到了mysql

11.对初始的随机密码进行修改

           mysql>set password for root@localhost = password('root');

           Query OK, 0 rows affected, 1 warning (0.25 sec)

           将root用户的初始随机密码修改为root(自己设定的密码)

12.查看数据库mysq>show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| myoneweb           |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

恭喜你至此你已经成功安装完MySQL!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql 安装 win32 server