Home  >  Article  >  Database  >  collect! Solution to error reported after MacOSS installs MySQL through DMG file

collect! Solution to error reported after MacOSS installs MySQL through DMG file

php是最好的语言
php是最好的语言Original
2018-07-25 16:17:051541browse

Not everyone will encounter errors when installing MySQL on MacOS, but I have indeed encountered them. There are many pitfalls. Solving these problems independently is also a check on your basic knowledge, so I prefer that everyone first Check independently, and if it still doesn't work, read below.

After installing MySQL on MacOS through the DMG file. . . .

You may encounter these two headaches:

error1

Unable to connect to host 127.0.0.1 because access was denied.

Double-check your username and password and ensure that access from your 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 that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Your password has expired. To log in you must change it using a client that supports expired passwords.

Not everyone will encounter this problem, but I have indeed encountered them all, and there are many pitfalls here. Solving these problems independently is also a check on your own basic knowledge, so I prefer that everyone investigate independently first, and if they are still not solved, then read the following. In addition, if you are in the Homestead environment officially recommended by laravel, you may not encounter these problems. But I am a person who loves to mess around. I especially like debugging and typing things in the command line, so I solved this problem and share it with you.

First, let’s reproduce the entire process starting from installing MySQL.

1. Download the MySQL dmg installation package from the mysql official website: https://dev.mysql.com/downloads/mysql/

2. After downloading the dmg file, double-click to install it. Note When you reach the last step, a prompt box will pop up:

collect! Solution to error reported after MacOSS installs MySQL through DMG file

root@localhost W:ivGGB5lrdS at the end is the initial password given to you when MySQL was installed. This is very important. Be sure to write it down.

3. Start MySQL:
Enter Mac’s System Preferences

collect! Solution to error reported after MacOSS installs MySQL through DMG file

collect! Solution to error reported after MacOSS installs MySQL through DMG file

## 4. After starting MySQL, I chose the software Sequel pro to operate the database.

collect! Solution to error reported after MacOSS installs MySQL through DMG file

At this time, the two previous errors will appear,

the
error1 mentioned above means your MySQL account password There is a mistake. I set up the database-related configuration in the .env file of the laravel project at the beginning, so I directly input the configuration in the .env file, and then it will prompt

Unable to connect to host 127.0.0.1 because access was denied.

Double-check your username and password and ensure that access from your current location is permitted.

MySQL said: Access denied for user 'root'@'localhost' (using password: YES)

Also

error2 In the error, the error message means: password has expired, which actually means that you cannot log in with the initial password you just installed MySQL. You need to reset your MySQL password and then use a new password. Let’s log in to the root account and let’s solve this problem.

First enter MySQL in command line mode

collect! Solution to error reported after MacOSS installs MySQL through DMG file

If nothing unexpected happens, you will see a prompt

mysql command not found

This is because We installed MySQL through a dmg file package. The system does not know MySQL. We need to add the MySQL path to the bash file (my command line tool uses zsh. Everyone uses it differently, but the idea is the same. Yes, just add the MySQL path to the bash file)

Open the bash file first, and then add the MySQL path.

collect! Solution to error reported after MacOSS installs MySQL through DMG file

Enter the following line of command in the opened file, save and exit to use MySQL commands on the command line.

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

collect! Solution to error reported after MacOSS installs MySQL through DMG file

After that, we need to reset the password of the MySQL root account, enter

mysql -u root -p

on the command line and then enter the initial password provided by MySQL. If The following prompt appears, indicating that we have entered the MySQL settings

295308797-5b52c932a8c7a_articlecollect! Solution to error reported after MacOSS installs MySQL through DMG file

At this time, we enter

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你想要设置的root账户的新密码');

after mysql > When we see

collect! Solution to error reported after MacOSS installs MySQL through DMG file

means that the password reset is successful, and then when we open Sequel pro and enter the root account and new password, it can be used.

collect! Solution to error reported after MacOSS installs MySQL through DMG file

collect! Solution to error reported after MacOSS installs MySQL through DMG file

Related recommendations:

After installing MySQL, an error errorNr.1364## was reported in the last step of configuration.

#Detailed graphic and text explanation of encoding settings for MySQL installation

Video tutorial: Install mysql-Alibaba Cloud environment construction and project launch

The above is the detailed content of collect! Solution to error reported after MacOSS installs MySQL through DMG file. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn