I installed MySQL on Mac using Homebrew, so I’ll introduce the procedure. (Last updated: 2017/03/25)
If you haven’t installed Homebrew yet, please refer to this article.
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)
If you want to change the character encoding of character_set_*, you can configure it by following the steps in Changing MySQL Character Encoding to UTF8.
That’s all from the Gemba!