Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save azurestone/6044314 to your computer and use it in GitHub Desktop.

Select an option

Save azurestone/6044314 to your computer and use it in GitHub Desktop.
mkdir -p ${HOME}/Data/mysql-5.6.10
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=${HOME}Data/mysql-5.6.10 --tmpdir=/tmp
cd /usr/local/opt/mysql
# datadir = のパスを追記する
vim
# パスワードを設定する
mysqladmin -u root password "パスワード"
# 起動スクリプトの配置
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
# 起動スクリプトの読み込み
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# MySQL 起動
mysql.server start
# ログイン権限の初期化
mysql_secure_installation
@azurestone
Copy link
Author

MySQL起動

mysql.server start

MySQL停止

mysql.server stop

@azurestone
Copy link
Author

設定:

設定ファイルのテンプレートの場所

$ ls $(brew --prefix mysql)/support-files/my-*
/usr/local/opt/mysql/support-files/my-default.cnf

設定ファイルをコピー

cp /usr/local/opt/mysql/support-files/my-default.cnf /usr/local/var/mysql/my.cnf

@azurestone
Copy link
Author

vim /usr/local/var/mysql/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

# 
max_allowed_packet=64M

# 
character-set-server = utf8

[mysql]

# 
default-character-set = utf8

@azurestone
Copy link
Author

設定を確認する

$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.10 Source distribution

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> status;
--------------
mysql  Ver 14.14 Distrib 5.6.10, for osx10.8 (x86_64) using  EditLine wrapper

Connection id:          1
Current database:
Current user:           god@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.6.10 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /tmp/mysql.sock
Uptime:                 18 sec

Threads: 1  Questions: 5  Slow queries: 0  Opens: 67  Flush tables: 1  Open tables: 60  Queries per second avg: 0.277
--------------

mysql>

@azurestone
Copy link
Author

自動起動をオフにする

vim Library/LaunchAgents/homebrew.mxcl.mysql.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>KeepAlive</key>
  <true/>
  <key>Label</key>
  <string>homebrew.mxcl.mysql</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/mysql/bin/mysqld_safe</string>
    <string>--bind-address=127.0.0.1</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/usr/local/var</string>
</dict>
</plist>
  • trueをfalseにする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment