Mac に MySQL を Homebrew でインストールしたので、その手順をご紹介します。(最終更新日:2017/03/25)
Homebrew のインストールがまだの方はこちらの記事をご参考にして下さい。
brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.17.el_capitan.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring mysql-5.7.17.el_capitan.bottle.1.tar.gz
==> Using the sandbox
==> /usr/local/Cellar/mysql/5.7.17/bin/mysqld --initialize-insecure --user=your_username --basedir=/usr/local/Cellar/mysql/5.7.17 --datadir=/usr/local/var/mysql --t
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
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.17: 321 files, 234.4MB
brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
mysql.server start
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 3
Server version: 5.7.17 Homebrew
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> show variables like 'character_set%';
+--------------------------+------------------------------------------------------+
| Variable_name | Value |
+--------------------------+------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/Cellar/mysql/5.7.17/share/mysql/charsets/ |
+--------------------------+------------------------------------------------------+
8 rows in set (0.01 sec)
character_set_* の文字コードを変更したい場合は、MySQL の文字コードを UTF8 に変更するの手順で設定できます。
カンタンですね!