哎,小弟第一次使用mac来办公,这个高大上的东东,确实和ubuntu有很多不同啊,不废话了,这里简单记录下我安装mysql遇到的问题和解决方案。
记录一下mysql数据库安装的过程。
- brew install mysql
接着如果你要执行mysql -uroot将会出现my.sock等异常信息。
所以我们应该做的是以下的操作。
1、查看安装信息
- brew info mysql
2、然后就需要你进行一些系统数据安装的操作。
- unset TMPDIR
- mysql_install_db --verbose --user=`whoami`--basedir="$(brew
--prefix mysql)"--datadir=/usr/local/opt/mysql --tmpdir=/tmp
如果这里出现一下错误:
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
这个错误是说 在你指定的路径找不到 ./bin/my_print_defaults 文件。既需要执行brew --prefix mysql命令去查看mysql安装的路径,在看到 bin文件夹的同一层目录执行此命令。
3、然后数据库服务
-
mysql.server start
如果遇到类似这样的错误 . ERROR! The server quit without updating PID file (/usr/local/var/mysql/jakedeMacBook-Air.local.pid).
表明mysql这个用户没有对此目录的写权限,可以试试:sudo chown -R groupname:username /usr/local/var/mysql/ 其中username是mysql
4、执行连接操作
1.mysql -uroot