1. 程式人生 > >2 數據庫開發--MySQL下載(windows)

2 數據庫開發--MySQL下載(windows)

type def password ear inter statement inf 方式 mini

Windows:(mysql)
操作:

0.下載安裝mysql
    www.mysql.org
    downloads->進入社區community
    community 5.7.21
    下載5.6 Microsoft Windows
    解壓到C:  C:\mysql-5.6.39-winx64
    C:\mysql-5.6.39-winx64\bin
        bin/mysql   客戶端
        bin/mysqld  服務端
    設置環境變量:
        我的電腦 屬性 高級系統設置 環境變量
        系統變量 Path 新建 將 前面加;  D:\mysql\mysql-5.6.41-winx64\bin
粘貼 確定... 啟動cmd: >>>:mysqld >>>:mysql 將mysqld做成系統服務,開機自動啟動: 1.先殺死之前開啟的mysqld: 技術分享圖片
           技術分享圖片
2.制作系統服務:
            C:\Users\Administrator>mysqld --install   制作系統服務
            Service successfully installed.
            C:\Users\Administrator
>mysqld --remove 解除系統服務 Service successfully removed.
技術分享圖片
3.服務
            服務-->MySQL-->啟動-->ok...
            或者:
            C:\Users\Administrator>net start MySQL
                MySQL 服務正在啟動 .
                MySQL 服務已經啟動成功。

            C:\Users\Administrator>net stop MySQL
                MySQL 服務正在停止.
                MySQL 服務已成功停止。

1.驗證安裝成功
C:\Users\Administrator>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.6.39 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> select user(); 註意標點符號也要加
+----------------+
| user() |
+----------------+
| ODBC@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> exit
Bye
2. root默認沒有密碼
技術分享圖片
3.設置初始密碼:
技術分享圖片
4.修改密碼
技術分享圖片

5.忘記密碼,破解密碼,跳過授權表;

 C:\Users\Administor>net stop MySQL
MySQL 服務正在停止.
MySQL 服務已成功停止。

C:\Users\Admininstor>mysqld --skip-grant-tables # 跳過授權表 啟動 mysqld
技術分享圖片

 C:\Users\Administor>mysql -uroot -p    # 跳過了授權 不需要輸入密碼了
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.6.39 MySQL Community Server (GPL)

    Copyright (c) 2000, 2018, 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> select user();
    +--------+
    | user() |
    +--------+
    | root@  |
    +--------+
    1 row in set (0.00 sec)

    mysql> update mysql.user set password=password("123") where user="root" and host="localhost";   # 修改密碼
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0

    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

    mysql> exit
    Bye

    C:\Users\Administor>mysql -uroot -p123   # 修改密碼成功
    Warning: Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 11
    Server version: 5.6.39 MySQL Community Server (GPL)

    Copyright (c) 2000, 2018, 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> select user();
    +----------------+
    | user()         |
    +----------------+
    | root@localhost |
    +----------------+
    1 row in set (0.00 sec)

    mysql> exit
    Bye

# 殺死之前 開啟的 跳過授權的 mysqld
C:\Users\Administrator>tasklist | findstr mysql
mysqld.exe 6460 Console 1 453,740 K

C:\Users\Administrator>taskkill /F /PID 66732
成功: 已終止 PID 為 6460 的進程。

C:\Users\Administrator>net start mysql
MySQL 服務正在啟動 .
MySQL 服務已經啟動成功。

C:\Users\Administrator>mysql -uroot -p123 # 用之前設置的密碼 登錄便可
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.39 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> exit
Bye

>mysql 套接字客戶端

6.登錄mysql的兩種方式:
    C:\Users\Administrator>mysql -uroot -p123
    C:\Users\Administrator>mysql -uroot -p123 -h 127.0.0.1 -P 3306  # 默認端口是3306
    Warning: Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 5.6.39 MySQL Community Server (GPL)

    Copyright (c) 2000, 2018, 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> select user();
    +----------------+
    | user()         |
    +----------------+
    | root@localhost |
    +----------------+
    1 row in set (0.00 sec)

    mysql> exit
    Bye

    C:\Users\Administrator>mysql -h 127.0.0.1 -P 3306
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 9
    Server version: 5.6.39 MySQL Community Server (GPL)

    Copyright (c) 2000, 2018, 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> select user();
    +----------------+
    | user()         |
    +----------------+
    | ODBC@localhost |
    +----------------+
    1 row in set (0.00 sec)

    mysql> exit
    Bye

7.統一字符編碼:

技術分享圖片

修改安裝目錄下的mysql配置文件

技術分享圖片

新建配置文件my.ini

粘貼內容:

#mysql5.5以上:修改方式有所改動
----------------------------------- [mysqld] character-set-server=utf8 collation-server=utf8_general_ci [client] default-character-set=utf8 [mysql] default-character-set=utf8
----------------------------------
#2. 重啟服務
#3. 查看修改結果:
\s
show variables like ‘%char%‘

技術分享圖片

2 數據庫開發--MySQL下載(windows)