MacOS Install MySQL and change root password

Source: Internet
Author: User
Tags mysql in

1. Download the installation package

http://

Find the following download

MYSQL-5.7.21-1-MACOS10.13-X86_64.DMG is

HTTPS://cdn.mysql.com//DOWNLOADS/MYSQL-5.7/MYSQL-5.7.21-1-MACOS10.13-X86_64.DMG 

2. After downloading, follow the prompts to install

Follow the installation steps to save the MySQL root password in the last pop-up box.

3. After installation, you need to start

Open the settings and click MySQL to open the MySQL server, if necessary, whether to start the boot

4. Setting Environment variables

At this point we enter the mysql-uroot-p command at the command line at this point, we will prompt for no commod not found, we also need to add MySQL to the system environment variable.

(1). Go to/usr/local/mysql/bin to see if there is MySQL in this directory.

(2). Perform Vim ~/.bash_profile

Add the Mysql/bin directory to the file:

Path= $PATH:/usr/local/mysql/bin

When you are finished adding, press ESC, and then enter Wq save.

Finally, enter source ~/.bash_profile on the command line

5, because I forgot the password, this step is the Mac under the change of MySQL password

To stop MySQL from the command line:

You have to use the root account.

Yuchaodemacbook-pro:support-files root#./
' /usr/local/mysql/data/yuchaodemacbook-pro.local.err ' . SUCCESS! yuchaodemacbook-pro:support-files root#./mysql.server stop shutting down MySQL. SUCCESS!
Yuchaodemacbook-pro:support-files root# pwd
/usr/local/mysql/support-files

6. If there is an error, there is no PID file

Delete/usr/local/mysql/data/*. Err

7, skip the authorization form, modify the password PS aux |grep mysql

#这一步, you must close mysql!!!!!! Skip Permission Validation
Yuchaodemacbook-pro:bin root#./mysqld_safe--skip-grant-tables &

#直接用root登陆, no password required
./mysql-uroot

#修改密码

Update Mysql.user set authentication_string =password (' Redhat ') where user= ' root ';

#刷新表
Flush privileges;

#重启mysql服务, the process of skipping the authorization form is automatically turned off!!
Yuchaodemacbook-pro:bin root#. /support-files/mysql.server restart

8.!!!!!!!!!!!!!!!!!!!!!!!!!

MacOS Install MySQL and change root password

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.