Install mysql on mac and mysql on mac

Source: Internet
Author: User
Tags install brew

Install mysql on mac and mysql on mac

There are two ways to install mysql under mac, one is to directly go to the http://dev.mysql.com/downloads/mysql/ to download a dmg installation package, and then one way to install. However, there is a problem here. Because the mac file system is different from linux, an error will be reported when mysql-u root-p is logged on after installation:

ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2)

There are specific solutions on the Internet, but I have never been successful. Therefore, the second method is decisively adopted to use brew for installation.

Brew is a software manager for mac, similar to apt-get install in linux. First install brew and go to http://brew.sh/, and run it in the ghost.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The installation is successful.

Then run the blew command to install mysql. execute the following command in sequence. Some of the steps are slow. Please be patient.

 brew install mysql
After the installation is complete, this error is still reported during login.

ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Run the following commands in sequence:

unset TMPDIR
mysql_install_db --verbose --user=root --basedir="$(brew --prefix mysql)"--datadir=/usr/local/var/mysql --tmpdir=/tmp

mysql.server start
Then you can log on. The logon command is:

mysql -uroot -p
To enable startup, run the following command:

mkdir -p ~/Library/LaunchAgents
Cp/usr/local/Cellar/mysql/5.6.16/homebrew. mxcl. mysql. plist ~ /Library/LaunchAgents/#5.6.16 is the database version number. You can modify it based on the version number you installed at the time.
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
So far, mysql is successfully installed on mac. Correct the error.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.