How to install MySQL on your MacBook

Source: Internet
Author: User
Tags macbook

  1. Download the MySQL installation package, if it is the first installation, we recommend downloading the DMG installation package

  2. Open the DMG installation package and double-click the pkg file in the installation package

  3. Click "Continue", and then click "Finish"

  4. When the installation is complete, open system preferences and you can see a MySQL icon in multiple places,

  5. Click on the "MySQL" icon, in the pop-up interface, we notice that MySQL has been started, and is powered on from boot.

  6. Once installed, it is a good idea to create a MySQL shortcut command that can be used directly in the terminal.

    Open terminal, enter command:

    sudo vim/etc/bashrc

  7. To add a command to create an alias in BASHRC:

    Alias MySQL '/usr/local/mysql/bin/mysql '

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

    After you finish editing, you need to use "wq!" command to force the content to be saved.

  8. Restart the terminal, and then set the MySQL root account, enter the command

    Mysqladmin-u Root Password 123456

    Ps:

    You may have an error when executing the above command:

    Mysqladmin:connect to server at ' localhost ' failed

    Error: ' Access denied for user ' root ' @ ' localhost ' (using Password:no) '

    If encountered, refer to "Connect to server at ' localhost ' failed"

    1connect to server at ' localhost ' failed

When MySQL is installed on the MacBook Pro, an error occurs when you execute mysqladmin to set the password for the root account.

Mysqladmin:connect to server at ' localhost ' failed

Error: ' Access denied for user ' root ' @ ' localhost ' (using Password:no) '

What to do?

Tools/Materials
    • MySQL 5.7
    • MacBook Pro
Method/Step
  1. Stop MySQL service first

    Open "System Preferences", select "MySQL", in the Open dialog box click "Stop mysql Server"

  2. Open terminal, enter command: Sudo/usr/local/mysql/bin/mysqld_safe--user=mysql--skip-grant-tables--skip-networking &

    --skip-grant-tables: Do not start grant-tables (authorization table), skip permission control.

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

  3. Keep the terminal open Mysqld_safe, create a new terminal, enter the command: MySQL

    At this point we can log in directly to the MySQL service.

  4. To query MySQL user information, enter the SQL command:

    Select host,user,authentication_string from user;

    This step is familiar to the person can skip, in the previous version of MySQL 5.7, the password column of the English name is password, but in 5.7 version changed to Authentication_string, this is to be noted.

  5. All we need to do is reset the username root password to enter the SQL command:

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

  6. After setting up the user or changing the password, flush privileges will be required to flush the MySQL system permission related tables, otherwise access is denied, and another way is to restart the MySQL server for the new settings to take effect

  7. Restart the MySQL service, open the terminal, enter the command:

    Mysql-uroot-p

    Enter the password you just set to successfully log in

How to install MySQL on your MacBook

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.