You are not logged in.

Important Note: This forum is being archived and will be completely locked down on the 7th of February. The new forum can be found at http://laravel.io.

Announcement

    Laravel 4 Advanced Architecture: Book Now On Sale

#1 2012-04-15 11:55:09

liamr
Apprentice
Registered: 2012-02-25
Posts: 1

Setting up MAMP / Laravel / migrations

I noticed that when using artisan migrate on my MAMP setup I would get this error:

No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

After digging around, the solution seems to be create a symlink from /var/mysql/mysql.sock to /Applications/MAMP/tmp/mysql/mysql.sock.

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

That fixed the problem for me. Hope this is useful to anyone else!

Liam

Offline

#2 2012-04-19 22:30:02

Meroje
Artisan
Registered: 2011-11-19
Posts: 60
Website

Re: Setting up MAMP / Laravel / migrations

I think you should better use the php executable bundled with mamp, by adding it to the end of your $PATH, it will then use the same version and configuration as mamp.

Offline

#3 2012-05-27 16:10:50

kristjanmik
Artisan
Registered: 2012-05-26
Posts: 10

Re: Setting up MAMP / Laravel / migrations

I ran the command and the symlink is now active for /var/mysql/mysql.sock. But I'm still getting this error:

Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/kristjanmik/Work/nfvi/trunk/skiptibok/site2/laravel/database/connectors/mysql.php on line 33
SQLSTATE[HY000] [2002] No such file or directory

I have been exploring the web for solutions but nothing works.
I'm running on MAMP PRO.
Does anyone know why this is still happening?
Thanks, Kristjan.

Offline

#4 2012-06-11 21:00:59

clomond
Apprentice
Registered: 2012-06-10
Posts: 1

Re: Setting up MAMP / Laravel / migrations

liamr wrote:

I noticed that when using artisan migrate on my MAMP setup I would get this error:

No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

After digging around, the solution seems to be create a symlink from /var/mysql/mysql.sock to /Applications/MAMP/tmp/mysql/mysql.sock.

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

That fixed the problem for me. Hope this is useful to anyone else!

Liam

Thanks, this solved my problem!

Offline

#5 2012-07-15 05:05:15

boparaiamrit
Apprentice
From: Amritsar, Punjab, India
Registered: 2012-07-15
Posts: 4

Re: Setting up MAMP / Laravel / migrations

I will definite work for MAMP
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

Last edited by boparaiamrit (2012-07-15 05:05:33)

Offline

#6 2012-07-21 17:46:06

JoelLarson
Artisan
From: Minnesota
Registered: 2012-07-01
Posts: 49

Re: Setting up MAMP / Laravel / migrations

This is how I resolved the problem:

'connections' => array(

		'mysql' => array(
			'driver'   => 'mysql',
			'host'     => 'localhost',
			'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',
			'database' => 'database',
			'username' => 'user',
			'password' => 'pass',
			'charset'  => 'utf8',
			'prefix'   => '',
		),

	),

You can pass an optional "unix_socket" to the array and specify the MAMP socket instead of the default location. This gets around the suggested solution for creating a symlink and I would say is the better solution.


Skype: joellarsonweb

Offline

#7 2012-07-21 22:26:25

sineld
Moderator
From: Bursa, Türkiye
Registered: 2012-05-18
Posts: 524
Website

Re: Setting up MAMP / Laravel / migrations

I had the same problem once,
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
worked for me but thanks @JoelLarson for letting me know about unix_socket.

Offline

#8 2012-09-02 22:40:57

benbartling
Artisan
Registered: 2012-09-02
Posts: 5

Re: Setting up MAMP / Laravel / migrations

Thanks @JoelLarson ... the unix_socket solution works perfect.

Offline

#9 2012-10-03 13:35:00

Andreyco
Apprentice
Registered: 2012-09-19
Posts: 5

Re: Setting up MAMP / Laravel / migrations

JoelLarson wrote:

This is how I resolved the problem:

'connections' => array(

		'mysql' => array(
			'driver'   => 'mysql',
			'host'     => 'localhost',
			'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',
			'database' => 'database',
			'username' => 'user',
			'password' => 'pass',
			'charset'  => 'utf8',
			'prefix'   => '',
		),

	),

You can pass an optional "unix_socket" to the array and specify the MAMP socket instead of the default location. This gets around the suggested solution for creating a symlink and I would say is the better solution.


Works great on XAMPP as well (using right path, ofc!)

Offline

#10 2012-11-23 01:56:32

larryg123
Apprentice
Registered: 2012-11-23
Posts: 2

Re: Setting up MAMP / Laravel / migrations

Tried on xampp. Couldn't figure it out.

Where is the directory in xampp to complete the migration?

Offline

#11 2012-11-23 02:23:54

larryg123
Apprentice
Registered: 2012-11-23
Posts: 2

Re: Setting up MAMP / Laravel / migrations

Did it using the terminal smile More complicated though

Offline

#12 2012-11-24 10:27:29

Halfjo
Apprentice
Registered: 2012-11-24
Posts: 1

Re: Setting up MAMP / Laravel / migrations

An other way, for fun wink

-> add :

export PATH="/Applications/MAMP/bin/php/php5.4.4/bin:$PATH"

at the bottom of your .bash_profile

-> and just

$ source .bash_profile

in the terminal session where you whant to use it.

Control this with :

$ which php

or

$ php -i | grep ini

Thanks for unix_socket tips.

Last edited by Halfjo (2012-11-24 10:29:27)

Offline

#13 2012-11-26 09:08:18

rv_057
Apprentice
Registered: 2012-11-26
Posts: 2

Re: Setting up MAMP / Laravel / migrations

JoelLarson wrote:

This is how I resolved the problem:

'connections' => array(

		'mysql' => array(
			'driver'   => 'mysql',
			'host'     => 'localhost',
			'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',
			'database' => 'database',
			'username' => 'user',
			'password' => 'pass',
			'charset'  => 'utf8',
			'prefix'   => '',
		),

	),

You can pass an optional "unix_socket" to the array and specify the MAMP socket instead of the default location. This gets around the suggested solution for creating a symlink and I would say is the better solution.

Thank you very much for your simple and useful solution smile

Offline

#14 2013-01-09 04:19:17

Jordan
Apprentice
From: Bend, Oregon
Registered: 2013-01-09
Posts: 4

Re: Setting up MAMP / Laravel / migrations

Thanks @JoelLarson
I am using XAMPP on Mac since I abandoned MAMP Pro a while back.
Here was the directory if it helps anyone else:

 /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock 

Everything is working now.

Offline

#15 2013-01-27 09:55:06

memelab
Artisan
From: Melbourne
Registered: 2013-01-27
Posts: 25

Re: Setting up MAMP / Laravel / migrations

Thanks all, adding

 /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock 

to the database config as recommend worked magic for XAMPP!

Offline

#16 2013-01-28 01:09:06

memelab
Artisan
From: Melbourne
Registered: 2013-01-27
Posts: 25

Re: Setting up MAMP / Laravel / migrations

Actually, today, adding the unix_socket setting is not working for me.. I see the command:

php artisan migrate:install

fail, but adding a symlink as described works well for me.  This was a necessary step in getting PongoCMS bundle to work for me.

Ta!

Mac 10.8.2
XAMPP 1.7.3
Laravel 3.2.13

Offline

#17 2013-01-28 01:16:33

tplaner
Artisan
Registered: 2012-03-26
Posts: 12

Re: Setting up MAMP / Laravel / migrations

You should be able to correct this by changing your host to "127.0.0.1:{port}" for example on MAMP the default MySQL port is 8889, so your config would look like this:

		'mysql' => array(
			// ...
			'host'     => '127.0.0.1:8889',
			// ...

You will likely need to change this back to localhost after running the migration.

Offline

#18 2013-05-02 03:02:55

incitonetworks
Artisan
From: Washington DC, USA
Registered: 2013-04-28
Posts: 64
Website

Re: Setting up MAMP / Laravel / migrations

My setup was Mountain lion + Apache that ships with Mountain Lion + Mysql 5.5 downloaded from Mysql + Custom compiled from Source PHP 5.4.14 so to fix this problem I did as mentioned earlier with one difference and that is this:

sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Thought I share in case anyone else has same issue.


- Laravel Specialist

Offline

#19 2013-06-02 00:38:00

nickthemagicman
Artisan
Registered: 2013-05-25
Posts: 9

Re: Setting up MAMP / Laravel / migrations

I just added the port and it worked great.

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost:3306',
        ......
        ),


tplaner, you gave me the idea. 
However, the default mysql port is 3306.

Cheers.

Last edited by nickthemagicman (2013-06-02 00:39:33)

Offline

#20 2013-09-09 20:03:13

jimmyattime
Apprentice
Registered: 2013-09-09
Posts: 1

Re: Setting up MAMP / Laravel / migrations

You can specify the port too:

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'port'      => '7777'
        ......
        ),

Offline

#21 2013-10-30 08:59:42

lukaserat
Artisan
From: Philippines
Registered: 2012-10-20
Posts: 36

Re: Setting up MAMP / Laravel / migrations

Thank you guys. Symlinking depends on what Environment you have, be aware.

Offline

Board footer

Powered by FluxBB

');