新しいCentOS6.2に、MySQL 5.6.10 (rpm)をインストールして、初期設定しました。作業記録を残しておきます。
rpmの取得とインストール
MySQLサイトから、MySQL Community Server のRPMをダウンロードして、rpmコマンドでインストールしました。
新しいマシンでしたので、足りないrpmパッケージのインストールや、古いMySQLライブラリの削除などの作業もありましたが、ここでは割愛します。
今回の対象rpmファイル(と、インストール後のMySQLパッケージ)は以下です。
# ls -1 MySQL-client-5.6.10-1.linux_glibc2.5.x86_64.rpm MySQL-devel-5.6.10-1.linux_glibc2.5.x86_64.rpm MySQL-embedded-5.6.10-1.linux_glibc2.5.x86_64.rpm MySQL-server-5.6.10-1.linux_glibc2.5.x86_64.rpm MySQL-shared-5.6.10-1.linux_glibc2.5.x86_64.rpm # rpm -qa | grep MySQL MySQL-client-5.6.10-1.linux_glibc2.5.x86_64 MySQL-shared-5.6.10-1.linux_glibc2.5.x86_64 MySQL-embedded-5.6.10-1.linux_glibc2.5.x86_64 MySQL-devel-5.6.10-1.linux_glibc2.5.x86_64 MySQL-server-5.6.10-1.linux_glibc2.5.x86_64 #
クライアントからの接続確認
インストール後に、/etc/my.cnf を配置し、/etc/init.d/mysql で起動します。
mysql の初期設定の過程で、パスワード設定の箇所で戸惑っていたのですが、
MySQL-server.rpm のインストール時に、標準出力にメッセージが表示されていたのを思い出しました。
メッセージの内容は以下です。
# rpm -i MySQL-server-5.6.10-1.linux_glibc2.5.x86_64.rpm (省略) A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER ! You will find that password in '/root/.mysql_secret'. You must change that password on your first connect, no other statement but 'SET PASSWORD' will be accepted. See the manual for the semantics of the 'password expired' flag. Also, the account for the anonymous user has been removed. In addition, you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test database. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems with the /usr/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as /usr/my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings #
これによると「/root/.mysql_secret」にランダムに設定されたパスワードが記載されているとの事で、実際に確認するとその通りでした。
そのパスワードを使ってログインできました。
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.6.10 Copyright (c) 2000, 2013, 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> exit Bye #
次に、「/usr/bin/mysql_secure_installation」を実行してみると、先に「SET PASSWORD」を実行するように怒られました。
(ERROR 1820 (HY000): You must SET PASSWORD before executing this statement)
パスワード変更後に、「/usr/bin/mysql_secure_installation」を実行して、anonymousユーザの削除、リモートからのrootログインの拒否、testデータベースの削除などを行います。
その後、mysqlコマンドでログインできる事を確認します。
# mysql -u root -p mysql Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 13 Server version: 5.6.10 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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 | +--------------------+ 3 rows in set (0.00 sec) mysql> exit Bye #
一旦ここまでの記録とします。
Pingback: 3月5日の注目記事 | Javable.Jp