Databases

Fix MySQL "Can't connect to local MySQL server through socket"

The MySQL server isn't running, or isn't where the client is looking. Start it, or connect over the network.

  1. Start MySQL
    Terminal
    brew services start mysql
  2. Or connect over the network instead
    Terminal
    mysql -u root -p -h 127.0.0.1

Check it worked

  1. Check it's running
    Terminal
    brew services list
  1. Start MySQLNeeds sudo
    Terminal · Ubuntu / Debian
    sudo systemctl start mysql
  2. Or connect over the network instead
    Terminal · Ubuntu / Debian
    mysql -u root -p -h 127.0.0.1

Check it worked

  1. Check it's running
    Terminal · Ubuntu / Debian
    systemctl status mysql
  1. Start the MySQL serviceRun as administrator
    PowerShell
    Get-Service *mysql* | Start-Service

    On Windows the error reads "Can't connect to MySQL server on localhost".

Check it worked

  1. Check it's running
    PowerShell
    Get-Service *mysql*