bind-address not present in my.cnf file - Laravel
Asked Answered
D

2

2

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

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

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 ?

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.?

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/

Please Help Me.

Display answered 7/9, 2015 at 11:39 Comment(0)
D
1

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,
        ],
Display answered 7/9, 2015 at 15:9 Comment(0)
C
0

verify your mysql service is running..try to

mysql service start or mysql service restart

Or you can checkout some of the suggestion given here Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Chutzpah answered 7/9, 2015 at 12:31 Comment(3)
Yeah, My MySql Service Running Very FineDisplay
for the bind-address, you can add it below myisam_sort_buffer_size and stop and start mysql service when doing the change.Chutzpah
Yes. I did. But, same issue. Any idea, how to rectify it.Display

© 2022 - 2024 — McMap. All rights reserved.