Install MySQL under Mac

Source: Internet
Author: User

There are two ways to install MySQL under Mac, one is to go directly to http://dev.mysql.com/downloads/mysql/to download a DMG installation package, and then install it all the way. However, there is a problem, because the Mac file system and Linux are still different, resulting in the installation of Mysql-u root-p when landing will be error:

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 haven't been successful. So decisively took the second method of installing with brew

Brew is a software manager for Mac, similar to the Linux apt-get install. First install brew, enter http://brew.sh/official website, run in terminal

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
can be installed successfully.

Then you use blew to install MySQL commands, and then execute the following command, some of which are slow to install, please wait patiently.

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

ERROR 2002 (HY000): Can not connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
Next, execute the following commands in turn:

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 in, and the login command is:

mysql -uroot -p
If you want to set up boot, execute 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, which modifies the  
according to the version number you installed at that time.
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
At this point, the MAC has successfully installed MySQL. The wrong place welcomes the communication.

Install MySQL under Mac

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.