MacBookでhomebrewインストールmysql完全チュートリアル

11049 ワード

brew install mysqlプロセス解析
brewのインストール
公式サイト:https://brew.sh/
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

mysqlのインストール
brew install mysql

インストール完了のヒントは次のとおりです.
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.21.sierra.bottle.
######################################################################## 100.0%
==> Pouring mysql-5.7.21.sierra.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.7.21/bin/mysqld --initialize-insecure --user=xuemi
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
��  /usr/local/Cellar/mysql/5.7.21: 323 files, 233.9MB

注意:
  • プロンプトが次の場合:
  • ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    mysqlサービスが起動していない場合は、次の手順に従います.
    mysql.server start

    mysqlサーバの起動が完了したことを示すプロンプトが表示されます.
    Starting MySQL
    . SUCCESS!

    mysqlの設定
    端末で次のコマンドを実行します.
    mysql_secure_installation

    次のプロンプトが表示されます.
    Securing the MySQL server deployment.
    
    Connecting to MySQL using a blank password.
    //                    。        ,                 。            ?
    VALIDATE PASSWORD PLUGIN can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD plugin?
    //         y  Y,          
    Press y|Y for Yes, any other key for No:y
    
    //            :
    //    > = 8
    //    >= 8,  ,    ,     。
    //    >= 8,  ,    ,         。
    
    There are three levels of password validation policy:
    
    LOW    Length >= 8
    MEDIUM Length >= 8, numeric, mixed case, and special characters
    STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
    
    // 0,1,2    3      ,               
    
    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:0
    
    //       root   。
    //    :
    //        :
    //       :50。
    
    //           ?(  y| y Yes,       ):
    
    
    Please set the password for root here.
    
    New password:
    
    Re-enter new password:
    
    Estimated strength of the password: 50
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :y
    
    //      ,MySQL       ,
    //                MySQL。
    //           。      。
    //   ,        。
    //        ,        。
    //   。
    //       ?(  y| y Yes,       ):
    
    By default, a MySQL installation has an anonymous user,
    allowing anyone to log into MySQL without having to have
    a user account created for them. This is intended only for
    testing, and to make the installation go a bit smoother.
    You should remove them before moving into a production
    environment.
    
    Remove anonymous users? (Press y|Y for Yes, any other key for No) :y
    
    //   。
    //   ,        。
    // “localhost”。          。
    //         。
    //      root   ?(  y| y Yes,       ):
    //             root  ,        ,    Y
    
    Success.
    
    Normally, root should only be allowed to connect from
    'localhost'. This ensures that someone cannot guess at
    the root password from the network.
    
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) :y
    
      。
    
    //      ,MySQL      “test”    。
    //         。       ,
    //              。
    //   。
    //         mysql test   
    
    
               ?(  y| y Yes,       ):
    
    Success.
    
    By default, MySQL comes with a database named 'test' that
    anyone can access. This is also intended only for testing,
    and should be removed before moving into a production
    environment.
    
    
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) :y
    
    
    // ——       ……
    //   。
    // -           …
    //   。
    //               。
    //      ,     。
    //           ?(  y| y Yes,       ):
    - Dropping test database...
    Success.
    
     - Removing privileges on test database...
    Success.
    
    Reloading the privilege tables will ensure that all changes
    made so far will take effect immediately.
    
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) :y
    
    
    Success.
    //     ,  mysql    ,      mysql  
    All done!

    mysqlにログインしてテストを行います
    mysql -u root -p