Install MySQL under Mac

Source: Internet
Author: User

There are two ways to install MySQL: 1 for the official Download DMG installation package. 2 Install for use with brew.

Installation steps:

First, the official download DMG installation package for installation

1. Download the website

https://downloads.mysql.com/archives/community/

View Original

2. Unpack the pkg file

View Original

3. Installation

View Original

View Original

View Original

View Original

Installation is complete.

4. Testing

▲ Verify the installation is successful, enter the/usr/local/mysql/bin/, and use the LS command to see if there is MySQL

View Original

▲ Start MySQL service, enter the following command:

Sudo/usr/local/mysql/support-files/mysql.server start

Note that start is start, then stop is stop and the command is the following:

Sudo/usr/local/mysql/support-files/mysql.server stop

▲ Modify MySQL initialization password

Avoid service has started, so the first step is to shut down the MySQL service first

Sudo/usr/local/mysql/support-files/mysql.server stop

Enable Safe mode to start MySQL, this way can not enter the default password

Sudo/usr/local/mysql/bin/mysqld_safe--skip-grant-tables

The following screen appears to start successfully

View Original

At this point, close the Terminal window, and then restart a

Enter/usr/local/mysql/bin/, start MySQL as root

./mysql-u Root

View Original

Enter the following command to change the password, where password is the password to set

UPDATE mysql.user SET authentication_string=password (' root ') WHERE user= ' root ';
FLUSH privileges;

View Original

Exit MySQL, enter

Quit

Stop MySQL Service

Sudo/usr/local/mysql/support-files/mysql.server stop

Start the MySQL service again

Sudo/usr/local/mysql/support-files/mysql.server start

View Original

Use the following command to enter MySQL

./mysql-u Root-p

At this point, a password is required, which is the root password set previously

View Original

Re-test is normal

show databases;

At this point, if it appears:error 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. The wrong You need to set the password again when you mistakenly prompt

SET PASSWORD = PASSWORD (' root ');

View Original

Re-test is normal

View Original

Everything is fine.

5. Optimized use

▲ through the above operation, every time to go into the MySQL directory to start, then there are two ways alias and Ln to set up, Ln actually does not recommend, the path is a big problem. It is recommended to use alias.

Alias Mysql=/usr/local/mysql/bin/mysql

6, something

In fact, the comparison found that with DMG-a subcontract installation has many advantages, such as boot automatically start these, all have GUI tools to use

The system preferences are as follows:

View Original

View Original

Therefore, it is highly recommended to use this method to install in the development environment.

For Linux, the command-line operation is preferred.

Second, install MySQL using the Brew command

1. Direct input

Brew Install MySQL

2, the remaining steps refer to the above, basically consistent.

Install MySQL under Mac

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.