データベース/MySQL

目次

MySQL on Windows のインストール

インストール

  1. https://dev.mysql.com/downloads/mysql/ からWindows (x86, 64-bit), ZIP Archiveの小さいほうをダウンロード
  2. Zipを展開し,C:\mysql にコピー
  3. C:\mysqlの下にdataフォルダを作る
  4. C:\mysqlの下に,my.iniを作り,以下の内容を記述
    [mysqld]
    # set basedir to your installation path
    basedir=C:/mysql
    # set datadir to the location of your data directory
    datadir=C:/mysql/data
  5. 左下のWindowsの窓にcmdと入れる.出てきたコマンドプロンプトのアイコンを右クリック→管理者で実行
  6. 以下のコマンドをコマンドプロンプトで入力
    > cd C:\mysql\bin
    > mysqld --initialize --console
  7. このとき画面にはかれるパスワードをメモっておくこと(最後のやつ)
    2020-04-29T02:24:19.870696Z 0 [System] [MY-013169] [Server] c:\mysql\bin\mysqld.exe (mysqld 8.0.20) initializing of server in progress as process 9100
    2020-04-29T02:24:19.885207Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2020-04-29T02:24:20.948293Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2020-04-29T02:24:23.220643Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 3yWmcM,UdJ&M

サーバの起動

  1. コマンドラインプロンプトから以下を実行する
    mysqld --console
  2. アクセスを許可する
  3. これでサーバが立ち上がった(次回以降はこの作業だけでよい)

クライアントの起動

  1. 同じように,コマンドプロンプトを開いて,クライアントmysqlを立ち上げる
    c:\mysql\bin>mysql -u root -p
    Enter password: ************(さっきのパスワード)
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 10
    Server version: 8.0.20
    
    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>
  2. パスワードを更新しておく
     mysql> ALTER USER `root`@`localhost` IDENTIFIED BY 'new_password', `root`@`localhost` PASSWORD EXPIRE NEVER;

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS