MacPorts + MySQL5.7
プライベートな環境を久々に更新しようと思ってやったら思いの外はまった。
仕事は homebrew だけどプライベートマシンは MacPorts を使ってる。
*1
Python3.6.0, MySQL5.6 だったので Python3.6.1, MySQL5.7.17 にするかとports upgrade outdated して、MySQL を新規にインストールしようとしたらどハマりしたのでメモ。
入れる先。
- /opt/local/var/run/mysql57
- /opt/local/var/db/mysql57
- /opt/local/var/log/mysql57
`$ sudo -u _mysql /opt/local/lib/mysql57/bin/mysqld --initialize` をするとに権限がないと怒られるので、`--tmpdir=/tmp` をつける。
`$ sudo /opt/local/lib/mysql57/bin/mysqld --initialize --user=_mysql --tmpdir=/tmp`
これでログに色々非推奨になったものとかが出てくるので、まずは my.cnf をきれいにする。
innodb_large_prefix -innodb_file_format=Barracuda -sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES" +sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER" +explicit_defaults_for_timestamp=1
これで非推奨な警告らしいものは消えた。
起動したはずだからログに出てるパスワードを使って cli から接続してみると、
Error: Can't connect to local MySQL server through socket '/opt/local/var/run/mysql57/mysqld.sock' (2)
が出た。
/opt/local/var/run/mysql57 に mysql.sock を touch し chown _mysql しておく。
それでもまだ同じのが出るので、ググったら、
`secure-file-priv` とやらを設定する必要がありそうだ。
+secure-file-priv=/opt/local/var/db/mysql57/files
/opt/local/var/db/mysql57/files を 770 に設定。
再度実行。
2017-07-17T04:45:09.183964Z 0 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql57/ is case insensitive 2017-07-17T04:45:09.184760Z 0 [Warning] You need to use --log-bin to make --binlog-format work. 100 200 300 400 500 100 200 300 400 500 2017-07-17T04:45:11.707991Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-07-17T04:45:11.755651Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-07-17T04:45:11.815967Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: b7c42696-6aaa-11e7-ab9a-2c830cb15594. 2017-07-17T04:45:11.836664Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-07-17T04:45:12.110979Z 0 [Warning] CA certificate ca.pem is self signed. 2017-07-17T04:45:12.140515Z 1 [Note] A temporary password is generated for root@localhost: yMPR*aN3jPs. 2017-07-17T04:45:50.765696Z 0 [Warning] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory. 2017-07-17T04:45:50.766060Z 0 [Note] /opt/local/lib/mysql57/bin/mysqld (mysqld 5.7.17-log) starting as process 10452 ... 2017-07-17T04:45:50.768018Z 0 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql57/ is case insensitive 2017-07-17T04:45:50.768420Z 0 [Warning] You need to use --log-bin to make --binlog-format work. 2017-07-17T04:45:50.769777Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-07-17T04:45:50.769812Z 0 [Note] InnoDB: Uses event mutexes 2017-07-17T04:45:50.769827Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2017-07-17T04:45:50.769898Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2017-07-17T04:45:50.770818Z 0 [Note] InnoDB: Number of pools: 1 2017-07-17T04:45:50.770961Z 0 [Note] InnoDB: Using CPU crc32 instructions 2017-07-17T04:45:50.773358Z 0 [Note] InnoDB: Initializing buffer pool, total size = 512M, instances = 1, chunk size = 128M 2017-07-17T04:45:50.821204Z 0 [Note] InnoDB: Completed initialization of buffer pool 2017-07-17T04:45:50.880435Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2017-07-17T04:45:50.897177Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2017-07-17T04:45:50.897331Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2017-07-17T04:45:50.933367Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2017-07-17T04:45:50.934408Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2017-07-17T04:45:50.934428Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2017-07-17T04:45:50.934644Z 0 [Note] InnoDB: Waiting for purge to start 2017-07-17T04:45:51.059136Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 2534561 2017-07-17T04:45:51.059358Z 0 [Note] InnoDB: Loading buffer pool(s) from /opt/local/var/db/mysql57/ib_buffer_pool 2017-07-17T04:45:51.059568Z 0 [Note] Plugin 'FEDERATED' is disabled. 2017-07-17T04:45:51.061839Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170717 13:45:51 2017-07-17T04:45:51.069359Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2017-07-17T04:45:51.069387Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory. 2017-07-17T04:45:51.070018Z 0 [Warning] CA certificate ca.pem is self signed. 2017-07-17T04:45:51.070075Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory. 2017-07-17T04:45:51.077066Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306 2017-07-17T04:45:51.077602Z 0 [Note] - '127.0.0.1' resolves to '127.0.0.1'; 2017-07-17T04:45:51.077688Z 0 [Note] Server socket created on IP: '127.0.0.1'. 2017-07-17T04:45:51.093262Z 0 [Note] Event Scheduler: Loaded 0 events 2017-07-17T04:45:51.093377Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 2017-07-17T04:45:51.093393Z 0 [Note] Beginning of list of non-natively partitioned tables 2017-07-17T04:45:51.106188Z 0 [Note] End of list of non-natively partitioned tables 2017-07-17T04:45:51.106279Z 0 [Note] /opt/local/lib/mysql57/bin/mysqld: ready for connections. Version: '5.7.17-log' socket: '/opt/local/var/run/mysql57/mysql.sock' port: 3306 Source distribution
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17-log Copyright (c) 2000, 2016, 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>
動いた。大変だった。
*1:古いバージョンとか簡単に入って便利