MySQL特集1:インストール

5760 ワード

Mysql特集1:インストールと接続(Windows環境mysqlバージョン8.0以上)
1.Windowバージョンのダウンロード
https://dev.mysql.com/downloads/installer/
2.初期化
mysqld --initialize --console
C:\Users\Follow>mysqld --initialize --console
2020-04-07T09:14:11.438432Z 0 [System] [MY-013169] [Server] E:\mysql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progress as process 16388
2020-04-07T09:14:52.316112Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: fAWsp0s0mH=d

3.Mysqlサービスの起動
mysqld --console
C:\Users\Follow>mysqld --console
2020-04-07T09:21:36.435907Z 0 [System] [MY-010116] [Server] E:\mysql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) starting as process 5764
2020-04-07T09:21:45.574180Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-07T09:21:46.022142Z 0 [System] [MY-010931] [Server] E:\mysql-8.0.19-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.19'  socket: ''  port: 3306  MySQL Community Server - GPL.
2020-04-07T09:21:46.093546Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060

4.rootパスワードの接続と変更
新しいCMDウィンドウを開く
mysql-u root-p Enter password:fAWsp 0 s 0 mH=d(ステップ2で一時的なパスワードfAWsp 0 s 0 mH=dを生成)
alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘new Password’;
C:\Users\Follow>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19

Copyright (c) 2000, 2020, 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> alter user 'root'@'localhost' identified with mysql_native_password by 'root';
Query OK, 0 rows affected (0.24 sec)


4.切断して再接続
mysql> quit
Bye

新しく設定したパスワードを使用すると、接続に正常にアクセスできます.
C:\Users\Follow>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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>