Mysql for MAC installation and environment configuration

Source: Internet
Author: User
Tags mysql in

I. Download and Installation

First go to the official website to download the Mac version of MySQL, the suffix of the. DMG Package

: https://dev.mysql.com/downloads/mysql/

After downloading, a step-by-step fool installation, after installation, MySQL will pop up a box to tell you the installation and root user initial password, note that the MySQL for Mac initial password is randomly generated, it is best to remember

Two. Change the initial password

A. Open the terminal

1. Go to the MySQL Bin directory (the default installed directory is/usr/local/mysql/bin)

cd /usr/local/mysql/bin/

2. Enter the instruction and prompt for the password (enter the root password of the Mac account)

sudo./mysqld_safe--skip-grant-tables

3. After entering the password, you will find some hints, and MySQL will automatically restart

B. Open a different terminal

1. Input command 1: (go to the MySQL bin directory)
Input: cd /usr/local/mysql/bin/
2. Input Command 2:
Input: ./mysql
3. Go to MySQL command state: ( mysql> is the MySQL command status prompt)
Input:mysql> FLUSH PRIVILEGES;
4. Set Password root
Input:mysql> SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘root‘);

At this point, the initial password setup is complete

Three. Configure Environment variables

< Span class= "Apple-converted-space" >< Span class= "Apple-converted-space" >< Span class= "Apple-converted-space" If you do not set the environment variable, the input command is too cumbersome, each login mysql command is:/usr/local/mysql/bin/mysql-u root-p

The Windows system adds the MySQL path directly to the environment variables, and the MAC system needs to create a new path path to MySQL in the. bash_profile file in the home directory.

View Home directory:

Enter command Echo $HOME

The default home directory for Mac is the current user root directory /users/silverlaw

To configure environment variables:

1. Open the terminal and enter:

Open. Bash_profile

2. Enter the following statement directly:

Export Path=${path}:/usr/local/mysql/bin

Save, close terminal and TextEdit

Re-open the terminal, enter: Mysql-u root-p, you can successfully login

Mysql for MAC installation and environment configuration

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.