my.cnf 文件中不存在绑定地址 - Laravel

bind-address not present in my.cnf file - Laravel

当 运行 这个命令“php artisan migrate”时,我得到了这个错误“couldn't connect to local MYSQL server through socket”。

我浏览了所有 Whosebug 的答案,我得到了很多建议 'change bind-address:localhost to 127.0.0.1'。

我输入了这个命令“find / -name my.cnf”并得到了 'my.cnf' 文件的两个位置。

我很困惑..我要编辑哪个文件。哪一个是正确的路径?

而且,在我的 "my.cnf" 文件中,不存在 'bind-address'。 如果我手动写入,那么在 my.cnf 文件中的什么地方写入 "bind-address"?或者,我可以在该文件中写入的任何地方。?

这里是'my.cnf'文件

# The following options will be passed to all MySQL clients
[client]
#password   = your_password
port        = 3306
socket      = /opt/lampp/var/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
user = mysql
port=3306
socket      = /opt/lampp/var/mysql/mysql.sock
skip-external-locking
key_buffer = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

# Where do all the plugins live
plugin_dir = /opt/lampp/lib/mysql/plugin/

请帮助我。

验证您的 mysql 服务是 运行..尝试

mysql service start or mysql service restart

或者您可以查看此处给出的一些建议Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

我在 "Project-Folder-Name/config/database.php" 中进行了更改。而且,它奏效了。 添加了 'unix_socket' => '/opt/lampp/var/mysql/mysql.sock',

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'DatabaseName'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
        'unix_socket'   => '/opt/lampp/var/mysql/mysql.sock', //Your sock got from above
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],