MySQL installation

  1. Login website dev.mysql.com/downloads/m… Download mysql Community edition and select the installation package in DMG format.
  2. Once the download is complete, start the installation.
    • Note: Select Use Legacy Password Encryption.

Failed to start MySQL

  1. Open the mysql icon in the Settings, find the red dot, click “Start mysql Server”, turn green seconds after turning red, can not Start.

  1. Go to configuration, find the Error log location, and try to open it.

  1. Error: unable to open data folder, insufficient permissions. Reauthorization:
sudo chown -R mysql /usr/local/mysql/data
Copy the code
  1. Open the error file and report the error:Could not create unix socket lock file /usr/local/mysql/mysql.sock.lock.

This error usually indicates that the directory does not exist or has insufficient permissions, so we can create the directory directly by using the command.

mkdir -p /usr/local/mysql/ 
Copy the code

You can then set directory permissions

sudo chown -R mysql:mysql /usr/local/mysql/
Copy the code

Configure the MySQL

If you need to enter the Mysql command in the terminal, you need to perform the following configuration.

  1. Open file:open ~/.bash_profile
  2. Add statement:PATH=$PATH:/usr/local/mysql/bin
  3. To validate the configured statement:source ~/.bash_profile
  4. If the configuration is successful, enter the following command:mysql -uroot -pEnter the password and log in successfully

Resolve the login failure

ERROR 2002 (HY000): Can’t connect to local mysql server through socket ‘/ TMP /mysql.sock’ (2)

Open the /etc/my. CNF file and change the socket path

Screenshots for the modified ok, comment out the # socket = / TMP/mysql. The sock to modify before, will be in [client] and [mysqld] socket value instead of the socket = / usr/local/mysql/mysql. The sock note: Sudo vim /etc/my.cnf

Enter mysql -uroot -p to log in to mysql