Skip to content
Fix Code Error

Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (38)

March 13, 2021 by Code Error
Posted By: Anonymous

I am having a big problem trying to connect to mysql. When I run:

/usr/local/mysql/bin/mysql start

I have the following error :

Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)

I do have mysql.sock under the /var/mysql directory.

In /etc/my.cnf I have:

[client]
port=3306
socket=/var/mysql/mysql.sock

[mysqld]
port=3306
socket=/var/mysql/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M

and in /etc/php.ini I have :

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/mysql/mysql.sock

I have restarted apache using sudo /opt/local/apache2/bin/apachectl restart

But I still have the error.

Otherwise, I don’t know if that’s relevant but when I do mysql_config --sockets I get

--socket         [/tmp/mysql.sock]

Solution

If your file my.cnf (usually in the /etc/mysql/ folder) is correctly configured with

socket=/var/lib/mysql/mysql.sock

you can check if mysql is running with the following command:

mysqladmin -u root -p status

try changing your permission to mysql folder. If you are working locally, you can try:

sudo chmod -R 755 /var/lib/mysql/

that solved it for me

Answered By: Anonymous

Related Articles

  • Laravel: PDOException: could not find driver
  • error: 'Can't connect to local MySQL server through…
  • Plugin…
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • Name [jdbc/mydb] is not bound in this Context
  • Reference — What does this symbol mean in PHP?
  • How to set up a Subversion (SVN) server on GNU/Linux…
  • Apache server keeps crashing, "caught SIGTERM,…
  • Docker compose fails to start a service with an…
  • apache server reached MaxClients setting, consider…
  • getting error while updating Composer
  • How to remove MySQL completely with config and…
  • Exception in thread "JobGenerator"…
  • Failed to execute goal…
  • PHP7 : install ext-dom issue
  • Postgres could not connect to server
  • My kubernetes pods keep crashing with…
  • how to check and set max_allowed_packet mysql variable
  • Correct location of openssl.cnf file
  • Laravel blank white screen
  • java.lang.ClassNotFoundException: HttpServletRequest
  • How to see log files in MySQL?
  • Can't install laravel installer via composer
  • npm install error in vue
  • coercing to Unicode: need string or buffer, NoneType…
  • Neither BindingResult nor plain target object for…
  • PHP Warning: Module already loaded in Unknown on line 0
  • PySpark 3 - UDF to remove items from list column
  • "Non-resolvable parent POM: Could not transfer…
  • MySQL Server has gone away when importing large sql file
  • MySQL my.cnf performance tuning recommendations
  • Tomcat 7 "SEVERE: A child container failed during start"
  • Error message "Forbidden You don't have permission…
  • Why am I getting a "401 Unauthorized" error in Maven?
  • Problems using Maven and SSL behind proxy
  • How to set level logging to DEBUG in Tomcat?
  • Getting error: Can't connect to local MySQL server…
  • How can I start PostgreSQL server on Mac OS X?
  • Launching Spring application Address already in use
  • java.lang.RuntimeException: Unable to instantiate…
  • How do you sign a Certificate Signing Request with…
  • PHP-FPM and Nginx: 502 Bad Gateway
  • Content is not allowed in Prolog SAXParserException
  • Apache SSL Configuration Error (SSL Connection Error)
  • MySQL fails on: mysql "ERROR 1524 (HY000): Plugin…
  • Homebrew refusing to link OpenSSL
  • Exception in thread "main"…
  • no match for ‘operator
  • How to install Intellij IDEA on Ubuntu?
  • mysqli::mysqli(): (HY000/2002): Can't connect to…
  • Change the location of the ~ directory in a Windows…
  • Cannot install additional requirements to apache airflow
  • How do I get Flask to run on port 80?
  • cannot load such file -- bundler/setup (LoadError)
  • MySQL Error 1153 - Got a packet bigger than…
  • Install pip in docker
  • A fatal error has been detected by the Java Runtime…
  • configure: error: C compiler cannot create executables
  • Automapper map to tuple which first element is list…
  • PHP - Failed to open stream : No such file or directory
  • Virtual hosts not working properly in ubuntu LAMP stack
  • Automapper Aftermap alternative for Nested Mapping
  • fail to start mysql on CentOS7
  • When I'm testing a web app by JUnit and Mockito I…
  • Setting PHP tmp dir - PHP upload not working
  • How can I get around MySQL Errcode 13 with SELECT…
  • java.io.EOFException when reading from socket
  • What's causing my java.net.SocketException:…
  • How to create websockets server in PHP
  • Why does `which` print out a script?
  • Extracting stuffs from my Jenkins container docker…
  • Add to PATH from Laravel Sail Dockerfile
  • ActiveMQ Artemis in Docker shows empty screen
  • How can I generate a self-signed certificate with…
  • adb devices command not working
  • Can not connect to local PostgreSQL
  • PHP parse/syntax errors; and how to solve them
  • Running a simple JSF webapp on TOMEE-9.0 PLUS cannot…
  • How to change max_allowed_packet size
  • How do I install soap extension?
  • Maven does not find JUnit tests to run
  • HTTP Status 500 - org.apache.jasper.JasperException:…
  • How to use Elasticsearch with MongoDB?
  • How to install JSTL? The absolute uri:…
  • Is this very likely to create a memory leak in Tomcat?
  • How do you list volumes in docker containers?
  • Non-resolvable parent POM for Could not find…
  • how to use canvas in JavaScript flappy bird code
  • How to Configure JAVA_OPTIONS in linux
  • How to change XAMPP apache server port?
  • ImportError: No module named sqlalchemy
  • Start redis-server with config file
  • How can I install Apache Ant on Mac OS X?
  • No Spring WebApplicationInitializer types detected…
  • Error creating bean with name
  • Remote Connections Mysql Ubuntu
  • For homebrew mysql installs, where's my.cnf?
  • PHP Composer update "cannot allocate memory" error…
  • How can I successfully Build gRPC in C++?
  • Reference - What does this regex mean?

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Getting Chrome to accept self-signed localhost certificate

Next Post:

Find the version of an installed npm package

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error