Last active
November 26, 2015 23:37
-
-
Save ilovejs/3c4978a6642b2572e187 to your computer and use it in GitHub Desktop.
How to properly install mysql on mac 10.10.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MySQL 5.6 | |
1. Download officla one, since it create lib folder for you | |
2. After installation | |
- Lib directory: | |
/usr/local/mysql/lib | |
- Bin, Data dir: | |
/usr/local/mysql-5.6.27-osx10.8-x86_64/bin/mysql | |
/usr/local/mysql-5.6.27-osx10.8-x86_64/data/mysql | |
3. Link them !! in case django mysql driver complaint about *.dylib file. | |
[ref]: http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib | |
ln -s /usr/local/mysql/lib/libmysql* /usr/local/lib | |
4. Maybe if you install mysql 5.7 from homebrew.....: | |
- Auto run from system login: | |
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist | |
- 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 | |
5. Complaints from | |
A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. | |
Tips: | |
Reset password: | |
ALTER USER USER() IDENTIFIED BY '123321'; | |
other password reset but not working: | |
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER | |
UPDATE mysql.user SET Password=PASSWORD('123123') WHERE User='root'; | |
Regular command: | |
mysql.server start | |
mysqld status | |
mysql -u root -p | |
- Initial db user, table (kind of setup system defailt table for mysql) | |
mysqld --initialize | |
bash will return "A temporary password is generated for root@localhost: l;O)BshPD2h+" | |
or: | |
mysql_install_db --datadir=/usr/local/Cellar/mysql/5.7.9/data | |
even more complecated with plugin/data dir: | |
mysqld --basedir=/usr/local/Cellar/mysql/5.7.9 --datadir=/usr/local/Cellar/mysql/5.7.9/data --plugin-dir=/usr/local/Cellar/mysql/5.7.9/lib/plugin --log-error=/usr/local/Cellar/mysql/5.7.9/data/errors.err --pid-file=/usr/local/Cellar/mysql/5.7.9/data/pidfile.pid --skip-grant-tables | |
- remove old mysql data dir (if installed from Homebrew) | |
rm -rf /usr/local/var/mysql | |
- mysql pid error: | |
ref: http://stackoverflow.com/questions/4963171/mysql-server-startup-error-the-server-quit-without-updating-pid-file | |
- Some other smart install script (dangeraous, not recommand) | |
unset TMPDIR | |
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment