Solve the error command not found: mysql when entering mysql under Mac

Today I am going to use mysql to build a table, and the result of entering the mysql command results in an error command not found: mysql

error message

This prompt means that mysql cannot be found

1. First of all, make sure whether your mysql is started or not. In your [System Settings] --> scroll to the bottom on the left side to find mysql --> check whether mysql is started. If it does not start, start it first, if it starts, try to close it and start it again.

 2. If the error is still reported

It may be caused by the lack of mysql in the /usr/local/bin directory. The solution is to find the mysql command and map it to the /usr/local/bin directory.

(1) Check whether there is a mysql command in the /usr/local/bin directory, open the Finder --> click the top to go --> go to the folder

——"Input /usr/local/bin——>Enter to enter /usr/local/bin, there is no mysql command on my side

(2) Find the bin folder under the mysql installation path, you can directly click on this interface and then click on the upper folder

 Find your corresponding mysql version and then enter the bin folder, find the mysql command

 copy its path

(3) Enter on the command line

sudo ln -fs /usr/local/mysql-5.7.27-macos10.14-x86_64/bin/mysql /usr/local/bin

/usr/local/mysql-5.7.27-macos10.14-x86_64/bin/mysql is the path you just copied

Press Enter to run the command, ask for a password, and run after entering the password

Check whether the mysql command is running normally

 normal operation

Check if there is a mapping file under the usr/local/bin file

Mapping file already exists

problem solved 

Guess you like

Origin blog.csdn.net/jojo_oulaoula/article/details/131285147