Troubleshooting "mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists" Error
When attempting to launch the MySQL server using mysqld_safe, you may encounter the error message "Directory '/var/run/mysqld' for UNIX socket file don't exists." This issue can be resolved by examining the MySQL configuration file and creating the missing directory.
Check MySQL Configuration
First, verify if the socket file path has been manually changed in the MySQL configuration file, typically located at /etc/my.cnf or /etc/mysql/my.cnf. If the path differs from "/var/run/mysqld," update it accordingly and save the changes.
Create Missing Directory
If the socket file path is correct in the configuration file, the issue likely lies with the absence of the "/var/run/mysqld" directory. To resolve this, create the directory manually and set the correct ownership:
<code class="bash">mkdir -p /var/run/mysqld chown mysql:mysql /var/run/mysqld</code>
Restart MySQL Service
After creating the directory, restart the MySQL service to apply the changes:
<code class="bash">systemctl restart mysqld</code>
Verified Solution
If the problem persists, double-check that the MySQL user (usually 'mysql') has write permissions to the "/var/run/mysqld" directory. Additionally, ensure that the MySQL service is running and the required port (default: 3306) is open on your firewall.
The above is the detailed content of How to Fix the \'mysqld_safe Directory \'/var/run/mysqld\' for UNIX socket file don\'t exists\' Error?. For more information, please follow other related articles on the PHP Chinese website!