Last active
September 7, 2018 16:14
-
-
Save sandyxu/6317509 to your computer and use it in GitHub Desktop.
brew install mysql & my.cnf & init database & start mysql & change root password & uninstall & show character & some solution s
This file contains 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
1. brew安装mysql | |
$ brew install mysql | |
2. 创建或修改/usr/local/etc/my.cnf | |
https://gist.github.com/sandyxu/6317492 | |
3. 初始化 init database | |
$ unset TMPDIR | |
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp | |
4. 启动 start mysql | |
$ mkdir -p ~/Library/LaunchAgents | |
$ cp /usr/local/Cellar/mysql/5.5.29/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ | |
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist | |
5. 修改root用户的密码 | |
$ mysqladmin -uroot -p'old_pwd' password "new_pwd" | |
6. 卸载mysql | |
sudo rm /usr/local/mysql | |
sudo rm -rf /usr/local/mysql* | |
sudo rm -rf /Library/StartupItems/MySQLCOM | |
sudo rm -rf /Library/PreferencePanes/MySQL* | |
sudo rm -rf /var/db/receipts/com.mysql.* | |
sudo vim /etc/hostconfig | |
#remove the line MYSQLCOM=-YES- | |
sudo rm -rf /Library/Receipts/mysql* | |
sudo rm -rf /Library/Receipts/MySQL* | |
7. mysql utf8 查看 | |
mysql> SHOW VARIABLES LIKE 'collation%'; | |
+----------------------+-----------------+ | |
| Variable_name | Value | | |
+----------------------+-----------------+ | |
| collation_connection | utf8_general_ci | | |
| collation_database | utf8_unicode_ci | | |
| collation_server | utf8_unicode_ci | | |
+----------------------+-----------------+ | |
3 rows in set (0.00 sec) | |
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.5.27/share/mysql/charsets/ | | |
+--------------------------+------------------+ | |
8 rows in set (0.00 sec) | |
8. 一些问题的解决方法 | |
# question 1) Library not loaded: libmysqlclient.18.dylib (LoadError) | |
通过观察: | |
$ ls -l /usr/lib/libmysqlclient.18.dylib | |
lrwxr-xr-x 1 root wheel 44 8 21 12:19 /usr/lib/libmysqlclient.18.dylib -> /usr/local/mysql/lib/libmysqlclient.18.dylib | |
$ which mysql | |
/opt/boxen/homebrew/bin/mysql | |
$ cd /opt/boxen/homebrew/Cellar/mysql/5.6.13/lib/ | |
$ ls libmysqlclient* | |
libmysqlclient.18.dylib libmysqlclient.a libmysqlclient.dylib libmysqlclient_r.18.dylib | |
libmysqlclient_r.a libmysqlclient_r.dylib | |
解决: | |
$sudo ln -sf /opt/boxen/homebrew/Cellar/mysql/5.6.13/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment