my.cnf文件中不存在绑定地址-Laravel [英] bind-address not present in my.cnf file - Laravel

查看:79
本文介绍了my.cnf文件中不存在绑定地址-Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行此命令'php artisan migrate'时,出现此错误"couldn't connect to local MYSQL server through socket".

While running this command 'php artisan migrate', i got this error "couldn't connect to local MYSQL server through socket".

我正在查看所有stackoverflow答案,我得到了很多建议,说将bind-address:localhost更改为127.0.0.1".

I was going through all stackoverflow answers, i got many suggestions saying 'change bind-address:localhost to 127.0.0.1'.

我输入了此命令"find / -name my.cnf",并获得了"my.cnf"文件的两个位置.

I entered this command 'find / -name my.cnf' and got two locations of 'my.cnf' file.

  • /opt/lampp/etc/my.cnf
  • /etc/mysql/my.cnf

我很困惑.我必须编辑哪个文件.哪一条是正确的路径?

I've confusion.. Which file i've to edit. Which one is correct path ?

而且,在我的"my.cnf"文件中,没有绑定地址". 如果我手动编写,那么在my.cnf文件中的哪里写"bind-address"?或者,我可以在该文件中写入的任何位置??

And, in my "my.cnf" file, no 'bind-address' is present. If i write manually, so where to write "bind-address" in my.cnf file ? Or, anywhere i can write in that file.?

这是"my.cnf"文件

Here is 'my.cnf' file

# 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/

请帮助我.

推荐答案

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

I made changes in "Project-Folder-Name/config/database.php". And, it worked. Added '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,
        ],

这篇关于my.cnf文件中不存在绑定地址-Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆