mac brew install mysql

作業ログ貼っただけ

[shell gutter="false"] [astel@MacBook-Pro] $ brew install mysql ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mysql-5.6.19.mavericks.bottle.tar.gz Already downloaded: /Library/Caches/Homebrew/mysql-5.6.19.mavericks.bottle.tar.gz ==> Pouring mysql-5.6.19.mavericks.bottle.tar.gz ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly.

To connect: mysql -uroot

To have launchd start mysql at login: ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents Then to load mysql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist Or, if you don't want/need launchctl, you can just run: mysql.server start ==> /usr/local/Cellar/mysql/5.6.19/bin/mysql_install_db --verbose --user=astel --basedir=/usr/local/Cellar/mysql/5.6.19 --datadir=/usr/local/var/mysql --tmpdir=/tmp ==> Summary /usr/local/Cellar/mysql/5.6.19: 9537 files, 338M [astel@MacBook-Pro] $ brew info mysql mysql: stable 5.6.19 (bottled) http://dev.mysql.com/doc/refman/5.6/en/ Conflicts with: mariadb, mysql-cluster, mysql-connector-c, percona-server /usr/local/Cellar/mysql/5.6.19 (9537 files, 338M) * Poured from bottle From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/mysql.rb ==> Dependencies Build: cmake ✘ Required: openssl ✔ ==> Options --enable-debug Build with debug support --enable-local-infile Build with local infile loading support --enable-memcached Enable innodb-memcached support --universal Build a universal binary --with-archive-storage-engine Compile with the ARCHIVE storage engine enabled --with-blackhole-storage-engine Compile with the BLACKHOLE storage engine enabled --with-embedded Build the embedded server --with-tests Build with unit tests ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly.

To connect: mysql -uroot

To have launchd start mysql at login: ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents Then to load mysql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist Or, if you don't want/need launchctl, you can just run: mysql.server start [astel@MacBook-Pro] $ mysql.server start Starting MySQL SUCCESS! [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.19 Homebrew

Copyright (c) 2000, 2014, 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> exit Bye [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ mysql.server stop Shutting down MySQL .. ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid). [astel@MacBook-Pro] $ ls [astel@MacBook-Pro] $ mysql.server start Starting MySQL SUCCESS! [astel@MacBook-Pro] $ mysql.server status SUCCESS! MySQL running (94104) [astel@MacBook-Pro] $ mysql.server stop Shutting down MySQL .. ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid). [astel@MacBook-Pro] $ ls -lah /usr/local/var/mysql/MacBook-Pro.local.pid -rw-rw---- 1 astel admin 6B 7 11 14:48 /usr/local/var/mysql/MacBook-Pro.local.pid [astel@MacBook-Pro] $ chmod 666 /usr/local/var/mysql/MacBook-Pro.local.pid [astel@MacBook-Pro] $ ls -lah total 0 drwxr-xr-x 4 astel admin 136B 7 11 14:42 ./ drwxrwxr-x 19 root admin 646B 7 11 14:34 ../ drwxr-xr-x 3 astel admin 102B 6 20 16:48 lib/ drwxr-xr-x 11 astel admin 374B 7 11 14:48 mysql/ [astel@MacBook-Pro] $ ls -lah /usr/local/var/mysql/MacBook-Pro.local.pid -rw-rw-rw- 1 astel admin 6B 7 11 14:48 /usr/local/var/mysql/MacBook-Pro.local.pid [astel@MacBook-Pro] $ mysql.server stop Shutting down MySQL .. ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid). [astel@MacBook-Pro] $ chmod 660 /usr/local/var/mysql/MacBook-Pro.local.pid [astel@MacBook-Pro] $ ls -lah /usr/local/var/mysql/MacBook-Pro.local.pid -rw-rw---- 1 astel admin 6B 7 11 14:49 /usr/local/var/mysql/MacBook-Pro.local.pid [astel@MacBook-Pro] $ mysqladmin -u root password 'root' [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ mysql -u root -o ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [astel@MacBook-Pro] $ 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.6.19 Homebrew

Copyright (c) 2000, 2014, 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> exit Bye [astel@MacBook-Pro] $ mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here.

Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Unable to connect to the server as root user, giving up. Cleaning up... [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here.

Enter current password for root (enter for none): OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] New password: Sorry, you can't use an empty password here.

New password: Sorry, you can't use an empty password here.

New password: Sorry, you can't use an empty password here.

New password: Sorry, you can't use an empty password here.

New password: Sorry, you can't use an empty password here.

New password: Sorry, you can't use an empty password here.

New password: Sorry, you can't use an empty password here.

New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] ... Success!

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] ... Success!

By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.

Remove test database and access to it? [Y/n] - Dropping test database... ... Success! - Removing privileges on test database... ... Success!

Reloading the privilege tables will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? [Y/n] ... Success!

All done! If you've completed all of the above steps, your MySQL installation should now be secure.

Thanks for using MySQL!

Cleaning up... [astel@MacBook-Pro] $ mysql --help | grep my.cnf order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf [astel@MacBook-Pro] $ [astel@MacBook-Pro] $ touch /usr/local/etc/my.cnf [astel@MacBook-Pro] $ vi /usr/local/etc/my.cnf [astel@MacBook-Pro] $ mysql.server stop Shutting down MySQL .. SUCCESS! [astel@MacBook-Pro] $ mysql.server start Starting MySQL SUCCESS! [astel@MacBook-Pro] $ cat /usr/local/etc/my.cnf [client] port = 3306 socket = /tmp/mysql.sock

[mysql] show-warnings

safe-updates

prompt = '[\d] mysql> '

[mysqld]

basic

datadir = /usr/local/var/mysql

tmpdir = /tmp

port = 3306 socket = /tmp/mysql.sock character-set-server = utf8 default-storage-engine = InnoDB

max connections

max_connections = 64

table_open_cache = max_connections * tables used in one transaction + 5

table_open_cache = 800

table_definition_cache = all tables(50) + max_connections + 5

table_definition_cache = 400

open_files_limit = table_open_cache * 1.4

open_files_limit = 1120

global buffer

key_buffer_size = 16M query_cache_type = 0

innodb_buffer_pool_size = available memory for Mysql * 0.7

innodb_buffer_pool_size = 300M

thread buffer

read_buffer_size = 256K read_rnd_buffer_size = 512K join_buffer_size = 256K sort_buffer_size = 512K

InnoDB

innodb_file_per_table innodb_autoextend_increment = 64 innodb_log_files_in_group = 2

innodb_log_group_home_dir = /tmp

innodb_log_file_size = 128M innodb_log_buffer_size = 16M innodb_flush_log_at_trx_commit = 1 innodb_flush_neighbors=0

innodb_flush_method=O_DIRECT

innodb_thread_concurrency = 4 innodb_commit_concurrency = 4

log

log_output = /tmp

general_log = 0 slow_query_log = 0

[mysqldump]

max_allowed_packet = 16M

quick set-charset single-transaction [astel@MacBook-Pro] $ [/shell]