1. 程式人生 > >MySQL windows10下安裝最新版5 7 16

MySQL windows10下安裝最新版5 7 16

               

1下載安裝包

去官網下載,不過官網推陳出新比較快,永遠是最新的一個版本,這裡我放了在百度雲盤上,百度雲下載地址是:連結: https://pan.baidu.com/s/1jI5CGpK 密碼: yjkw

2解壓

下載出來的包名字:mysql-5.7.16-winx64.zip,滑鼠右鍵解壓mysql安裝包,解壓到D:\MySQL5716目錄下面。

3配置基本引數

配置my.ini

[mysqld]

 

basedir = D:\MySQL5716\

 

datadir = D:\MySQL5716\data

 

port = 3306

4庫初始化

以管理員身份administrator賬號進去cmd視窗介面,初始化mysql庫,會自動在my.inf檔案裡面的datadir目錄上建好data目錄的:

D:\MySQL5716\bin>mysqld.exe  --initialize

 

mysqld: Could not create or access the  registry key needed for the MySQL application

 

to log to the Windows EventLog. Run the  application with sufficient

 

privileges once to create the key, add  the key manually, or turn off

 

logging for that application.

   

C:\Users\mch>

Install:

 

D:\MySQL5716\bin>D:\MySQL5716\bin\mysqld.exe  -install

 

Install/Remove of the Service Denied!

   

C:\Users\mch>

執行完後,會在目錄看到err檔案,開啟檔案搜尋password,裡面會有如下的描述,可以看到root賬號初始化密碼,如下所示:

2016-12-13T06:23:05.678590Z 0 [Warning]  TIMESTAMP with implicit DEFAULT value is deprecated. Please use  --explicit_defaults_for_timestamp server option (see documentation for more  details).

 

2016-12-13T06:23:05.695700Z 0 [ERROR]  Cannot open Windows EventLog; check privileges, or start server with  --log_syslog=0

 

2016-12-13T06:23:05.695700Z 0 [ERROR]  Can't find error-message file 'D:\MySQL5716\share\errmsg.sys'. Check  error-message file location and 'lc-messages-dir' configuration directive.

 

2016-12-13T06:23:06.968561Z 0 [Warning]  InnoDB: New log files created, LSN=45790

 

2016-12-13T06:23:07.359516Z 0 [Warning]  InnoDB: Creating foreign key constraint system tables.

 

2016-12-13T06:23:07.563190Z 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:  9cc22678-c0fc-11e6-ae45-507b9d506141.

 

2016-12-13T06:23:07.594490Z 0 [Warning]  Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be  opened.

 

2016-12-13T06:23:07.594490Z 1 [Note] A temporary password is  generated for [email protected]: HsApgaVUJ8-9

 

2016-12-13T07:37:58.619588Z 0 [Warning]  option 'new': boolean value 't' wasn't recognized. Set to OFF.

5啟動MySQL服務

啟動:

D:\MySQL5716\bin>mysqld.exe -nt  --skip-grant-tables

 

mysqld: Could not create or access the  registry key needed for the MySQL application

 

to log to the Windows EventLog. Run the  application with sufficient

 

privileges once to create the key, add  the key manually, or turn off

 

logging for that application.

然後再開一個cmd視窗,使用mysql登陸

D:\MySQL5716\bin>mysql

 

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

 

Your MySQL connection id is 2

 

Server version: 5.7.16 MySQL Community  Server (GPL)

   

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> show databases;

 

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

 

| Database           |

 

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

 

| information_schema |

 

| mysql              |

 

| performance_schema |

 

| sys                |

 

| test               |

 

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

 

5 rows in set (0.00 sec)

   

mysql> show grants;

 

ERROR 1290 (HY000): The MySQL server is  running with the --skip-grant-tables option so it cannot execute this  statement

 

mysql> use test;

 

Database changed

 

mysql> create table z1(id int,cn  varchar(10)) comment='only a test table .';

 

Query OK, 0 rows affected (0.34 sec)

   

mysql>

6修改root密碼

修改密碼:

mysql> update MySQL.user set  authentication_string=password('root') where user='root';

 

Query OK, 1 row affected, 1 warning (0.00  sec)

 

Rows matched: 1  Changed: 1   Warnings: 1

   

mysql> flush privileges;

 

Query OK, 0 rows affected (0.00 sec)

   

mysql>

7關閉MySQL服務

滑鼠底下右擊工具欄-> 啟動工作管理員-> 程序-> 右擊mysqld.exe,選擇結束程序。

8設定開機啟動

設定命令是:D:\MySQL5716\bin\mysqld.exe --install mysqld--defaults-file="D:\MySQL5716\my.ini",其中後面的file是mysql啟動的引數檔案,中間的mysqld是服務名。

如果報錯,Install/Remove of the Service Denied!,那是你沒有以管理員administrator啟動,即使你當前使用者在administrator使用者組裡面,還是會報一模一樣的錯誤,如下圖12.png所示:

 

這裡執行的時候,注意了,以administrator執行cmd.exe;操作過程是,在下面電腦的左下角搜尋框輸入cmd.exe,回車會彈出黑色的cmd.exe標示,然後再上面右鍵點選,選擇以系統管理員的身份開啟,如下所示,12.png

然後執行命令設定,就順利設定成功了。

Microsoft Windows [版本 10.0.14393]

 

(c) 2016 Microsoft Corporation。保留所有權利。

   

C:\Windows\system32>cd D:MySQL5716\bin

 

C:\Windows\system32>cd D:MySQL5716\bin

   

C:\Windows\system32>D:

   

D:\MySQL5716\bin>

 

D:\MySQL5716\bin>

 

D:\MySQL5716\bin>D:\MySQL5716\bin\mysqld.exe  --install mysqld --defaults-file="D:\MySQL5716\my.ini"

 

Service successfully installed.

   

D:\MySQL5716\bin>

然後檢視,可以使用service命令來啟動了