MacOS System Installation MySQL

Source: Internet
Author: User

Installation is simple the key is to be aware of the post-installation configuration. There are a lot of articles on the Internet that introduce the problems I encountered during the installation process.

The first step Download the MacOS version on the MySQL website and install the prompt step-by-step installation. After the installation is complete, in "system Preferences" there is a MySQL icon open found can set the MySQL service to boot and turn off the MySQL service.

Step Two It is inconvenient to enter commands in the/usr/local/mysql directory after MySQL installation, so it is best to create MySQL shortcut commands that can be used directly in the terminal. Of course, if you're not bothered, you can ignore this step by entering the full path command every time

Open Terminal input command sudo vim/etc/bashrc

Add the shortcut commands you want in BASHRC, such as

Alias mysqlstart= ' sudo/usr/local/mysql/support-files/mysql.server start '

Alias mysqlstop= ' Sudo/usr/local/mysql/support-files/mysql.server stop '

Alias mysql= '/usr/local/mysql/bin/mysql '

Alias mysqladmin= '/usr/local/mysql/bin/mysqladmin '

Use "wq!" when you are finished editing command to force the content to be saved.

Step three Restart the terminal and set the MySQL root account input command mysqladmin-u root Password 123456

PS: May error when executing the above command mysqladmin:connect to server at ' localhost ' failed error: ' Access denied for user ' root ' @ ' localhost ' (using password:no) '

Fourth Step resolve the issue in the previous step.

The idea is to pass the command mysqld_safe skip permission control to start the service and then log in to locate the record root user's table to modify its password. The operation is as follows

Step 1: first turn off the MySQL service

Step 2: open terminal input command sudo/usr/local/mysql/bin/mysqld_safe--skip-grant-tables--skip-networking &

--skip-grant-tables does not start grant-tables (authorization table) and skips permission control.

--skip-networking Skips the TCP/IP protocol only on native access (this option is not required.) Can not be used)

Step 3: keep open Mysqld_safe terminal to create a new terminal input command MySQL now we can log in directly to the MySQL service.

Query MySQL user information input SQL command

Select host,user,authentication_string from user;

We just need to reset the username root password to enter the SQL command

Update user set Authentication_string=password (' 123456 ') where user= ' root ' and host= ' localhost ';

After you set up a user or change your password, you need to flush privileges to refresh the MySQL system permissions related table otherwise there will be access denied another way is to restart the MySQL server for the new settings to take effect. Input command flush privileges;

Step 4: Restart the MySQL service open the Terminal Input command mysql-uroot-p Enter the password you just set to successfully log in.

But after I successfully login show databases View Database error You must reset your password using ALTER USER statement before executing. ...

Fifth Step resolve the issue in the previous step.

Step 1:set PASSWORD = PASSWORD ('your new PASSWORD');

Step 2:alter USER ' root ' @ ' localhost ' PASSWORD EXPIRE never;

Step 3:flush privileges;

Complete the above three steps to exit and re-login with the new settings of the password on the line above in addition to the red of their own changes to the new password other than the input can be.

This completes the MySQL installation.


MacOS System Installation MySQL

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.