Mysql 5.7.9インストールエラーメモ

14523 ワード

これは見ないでください.当時書いたときは料理が追い詰められていました.もちろん今もそうです.
バイナリインストール
 mysql_install_db --defaults-file=/data/mysqldata/3306/my.cnf --datadir=/data/mysqldata/3306/data --basedir=/usr/local/mysql --user=mysql
2015-12-04 21:18:14 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2015-12-04 21:18:14 [ERROR]   Child process: /usr/local/mysql/bin/mysqldterminated prematurely with errno= 32
2015-12-04 21:18:14 [ERROR]   Failed to execute /usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --bootstrap --datadir=/data/mysqldata/3306/data --lc-messages-dir=/usr/local/mysql/share --lc-messages=en_US --basedir=/usr/local/mysql
-- server log begin --
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

mysql_install_dbは廃棄され、代わりにmysqld-initialize
エラーはlibaioが見つからないことを示しています.so.1
error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory Warning MySQL has a dependency on the libaio library. Data directory initialization and subsequent server startup steps will fail if this library is not installed locally. If necessary, install it using the appropriate package manager. For example, on
Yum-based systems:
shell> yum search libaio  # search for info
shell> yum install libaio # install library

Or, on APT-based systems:
shell> apt-cache search libaio # search for info
shell> apt-get install libaio1 # install library

Mysqlはlibaio libraryに依存している.libaioをインストールしたら
root@Fan:/data# /usr/local/mysql/bin/mysqld --initialize --defaults-file=/data/mysqldata/3306/my.cnf --datadir=/data/mysqldata/3306/data --basedir=/usr/local/mysql --user=mysql
2015-12-04T13:22:01.848446Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-12-04T13:22:03.639997Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-12-04T13:22:04.002719Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-12-04T13:22:04.167369Z 0 [ERROR] unknown variable 'defaults-file=/data/mysqldata/3306/my.cnf'
2015-12-04T13:22:04.167408Z 0 [ERROR] Aborting

unknown variable ‘defaults-file=/data/mysqldata/3306/my.cnf’–defaults-fileオプションは一番前に
Then invoke mysqld as follows (enter the command on a single line with the–defaults-file option first):
shell> bin/mysqld --defaults-file=/opt/mysql/mysql/etc/my.cnf
         --initialize --user=mysql

initialize the data directory, invoke mysqld with the–initialize or –initialize-insecure option, depending on whether you want the server to generate a random initial password for the ‘root’@’localhost’ account. On Unix and Unix-like systems, it is important to make sure that the database directories and files are owned by themysql login account so that the server has read and write access to them when you run it later. To ensure this if you run mysqld as root, include the–user option as shown here:
重要なのは、データベースのディレクトリとファイルがMySQLログインアカウントに属していることを確認し、サーバに読み書き権限を持たせることです.rootユーザーを介してmysqldを実行する場合は、–userパラメータを持参します.
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysqld --initialize-insecure --user=mysql

Regardless of platform, use–initialize for “secure by default” installation (that is, including generation of a random initialrootpassword). In this case, the password is marked as expired and you will need to choose a new one. With the–initialize-insecure option, noroot password is generated; it is assumed that you will assign a password to the account in timely fashion before putting the server into production use.
-initializeは-initialize-insecureとは異なり、ランダムなrootパスワードを作成します.
実行を続け、またエラーを報告します.
root@Fan:/data/mysqldata/3306# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --initialize-insecure --user=mysql
2015-12-04T13:27:38.504948Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2015-12-04T13:27:38.504999Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2015-12-04T13:27:38.508994Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation
2015-12-04T13:27:38.509070Z 0 [ERROR] Aborting
root@Fan:/data/mysqldata/3306# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --initialize-insecure --user=mysql

重要なのはYou have enabled the binary log,but you haven’t provided the mandatory server-id.Please refer to the proper server start-up parameters documentation binlogを有効にしたがserver-idを設定しなかったのでmy.cnfにserver-idを追加
再初期化に成功しましたが、何のヒントもなくmysqlを起動しようとしましたが、成功しました.
mysql@Fan:~$ mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &
[1] 28843
mysql@Fan:~$ 151204 21:32:05 mysqld_safe Logging to '/data/mysqldata/3306/data/../mysql-error.log'.
151204 21:32:05 mysqld_safe Starting mysqld daemon with databases from /data/mysqldata/3306/data
mysql@Fan:/data/mysqldata/3306$ mysql -uroot -p -S /data/mysqldata/3306/mysql.sock 
Enter password:   ---       ,      ,         --initialize-insecure
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.9-log MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> 
mysql> select user,host from mysql.user;
+-----------+-----------+
| user      | host      |
+-----------+-----------+
| mysql.sys | localhost |
| root      | localhost |
+-----------+-----------+
2 rows in set (0.00 sec)

パスワードを変更
mysql@Fan:/data/mysqldata/3306$ mysqladmin -S /data/mysqldata/3306/mysql.sock -uroot -p password mysql
Enter password: 
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.