Collection! Macoss solution for error after installing MySQL via DMG file

Source: Internet
Author: User
Tags mysql in mysql login
Not everyone will encounter MacOS installed MySQL error, but I do have met, this inside pit is more, independent to solve these problems, but also on your own basic knowledge of a check, so I prefer to be independent of all the first, if still not resolved to see the following.

MacOS after installing MySQL via DMG file ....

You may encounter these two headache tips:

Error1

Unable to connect to host 127.0.0.1 because Access is denied. Double-check your username and password and ensure that access from your the current location is permitted. MySQL said:access denied for user ' root ' @ ' localhost ' (using Password:yes)

Error2

Unable to connect to host 127.0.0.1, or the request timed out. Be sure that the address is correct and so you have the necessary privileges, or try increasing the connection timeout ( Currently seconds). MySQL said:your Password has expired. To log the must change it using a client that supports expired passwords.

Not everyone will encounter this problem, but I do have met, this inside pit is more, independent solve these problems, but also on your own basic knowledge of a check, so I prefer to be independent of all the first, if still not resolved to see the following. In addition, if you are in the Laravel officially recommended homestead environment, you may not encounter these problems. But I am a more love toss of people, especially like debug, especially like to knock things in the command line, so also by the way to solve the problem, to share a bit for you.

First, let's reproduce the entire process from the beginning of the installation of MySQL.

1. Download MySQL's DMG installation package on MySQL website: https://dev.mysql.com/downloads/mysql/

2, dmg file download, double-click the installation, notice the last step, will pop up a prompt box:

Root@localhost behind the W:ivggb5lrds this is the MySQL installation to give you the initial password, this is very important, be sure to write down.

3. Start MySQL:
System Preferences for entering Mac

4, after the good MySQL, I chose the sequel Pro this software to operate the database.

At this point, there will be two previous errors,
One of the Error1 mentioned above means that your MySQL account password is wrong, and I started setting up the database-related configuration in the. env file of the Laravel project, so I entered the configuration directly in the. env file and then prompted

Unable to connect to host 127.0.0.1 because Access is denied. Double-check your username and password and ensure that access from your the current location is permitted. MySQL said:access denied for user ' root ' @ ' localhost ' (using Password:yes)

In addition to the Error2 error, the error message means:
Password has expired, in fact, you can not use the initial password installed MySQL login, you need to reset your MySQL password, and then use the new password to login to the root account, then we solve the problem.

First enter MySQL in command line mode

No surprises, you'll see a hint.

MySQL command not found

This is because we are installed in the form of the DMG file package MySQL, the system does not know MySQL this thing, we need to add the MySQL path in the bash file (my command line tool uses the ZSH, everyone uses different, but the idea is the same, is to include the MySQL path in the bash file)
Open the Bash file first, and then add the MySQL path.

Enter the following line in the open file, save and exit to use the MySQL command at the command line.

Export path= $PATH:/usr/local/mysql/bin

After that, we need to reset the password for the MySQL root account and enter it on the command line

Mysql-u root-p

Then enter the initial password provided by MySQL, if prompted by the following instructions, we entered the MySQL settings

At this point, we type in MySQL > back

Set PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' New password for the root account you want to set up ');

When you see

It means that resetting the password is successful and we can use it when we open sequel Pro and enter the root account and the new 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.