Can't connect to local MySQL server error

Ryan Schmidt ryandesign at
Sun Aug 5 03:53:47 PDT 2012

On Aug 5, 2012, at 03:49, Rodolfo Aramayo wrote:

> On Sun, Aug 5, 2012 at 3:17 AM, Ryan Schmidt wrote:
>> Is the server running? that is, is the mysqld process running, as seen using "ps" or Activity Monitor?
> Yes
>> If not, does the MySQL log file say anything about why that is?
> No socket was being created.

I gathered that… did it say why no socket was being created?

> Now I had a "weird" experience:
> I had installed:
> mysql55
> mysql55-server
> mysql_select
> In addition to the
> mysql5 and
> mysql55-server
> I wasn't detecting this because the way "port search" was acting
> For example if I now search, I get:
>> port installed *mysql*
> None of the specified ports are installed.
>> port installed *mysql
> The following ports are currently installed:
>  p5.12-class-dbi-mysql @1.0.0_3 (active)
>  p5.12-datetime-format-mysql @0.40.0_3 (active)
>  p5.12-dbd-mysql @4.20.0_1+mysql5 (active)
>  php5-mysql @5.3.15_0+mysqlnd (active)
>> port installed mysql*
> None of the specified ports are installed.

Understand that the *shell* will expand these glob patterns if possible, before running MacPorts. So if you have an item named, say, "mysqlstuff" in the current directory, then "port installed mysql*" will be expanded by the shell to "port installed mysqlstuff" before MacPorts ever has a chance to see the command. Only if the glob doesn't match something in the current directory would the shell pass "port installed mysql*' to MacPorts. If you do not want the shell to expand the glob, quote the argument, as in "port installed 'mysql*'. Alternately you can use "port installed name:mysql" which is similar to "port installed '*mysql*'". The "port installed '*mysql*'" syntax uses globs, whereas the "port installed name:mysql" syntax uses Perl-compatible regular expressions.

>> port installed mysql
> None of the specified ports are installed.

This is not unexpected; there is no port called "mysql" so it cannot be installed. Globs are by default anchored on both ends so you must add asterisks where you want arbitrary characters to be matched. PCREs on the other hand are unanchored by default and you must anchor them if desired.

By example:

# Installed port whose name is mysql:
port installed name:^mysql$
port installed mysql

# Installed ports whose names begin with mysql:
port installed name:^mysql
port installed 'mysql*'

# Installed ports whose names end with mysql:
port installed name:mysql$
port installed '*mysql'

# Installed ports whose names contain mysql:
port installed name:mysql
port installed '*mysql*'
port installed | grep mysql

>> port installed | grep mysql
>  mysql5 @5.1.63_0 (active)
>  mysql5-server @5.1.63_0 (active)
>  p5.12-class-dbi-mysql @1.0.0_3 (active)
>  p5.12-datetime-format-mysql @0.40.0_3 (active)
>  p5.12-dbd-mysql @4.20.0_1+mysql5 (active)
>  php5-mysql @5.3.15_0+mysqlnd (active)
> Note how this last one search is more complete
> I was using the command" >port installed *mysql*" before thus failing
> to detect that I had installed extra mysql ports

Using grep is also reasonable, if you're more comfortable with that. grep by default uses old-style regular expressions, and can be made to use PCREs with the -E flag.

> I uninstalled mysql55, mysql55-server, mysql_ select AND uninstalled
> mysql5-server
> I then re-installed mysql5-server, re-booted and got the socket live
> But for a while I was under the impression the presence of the other
> mysql ports was interfering with the generation of the socket??

My understanding is that the new mysql55 and mysql51 families of ports should not interfere with one another nor with the old mysql5 family of ports.

> So things are working now

I'm glad you got it working, though I can't explain why it didn't work for you before.

> I need to learn where to place my wordpress (which is not up-to-date
> in MacPorts)

Feel free to attach a patch to this ticket to update the port:

The port's current maintainer appears to have left us (has not responded to multiple tickets and has not committed in 11 months) so if you're interested perhaps you could take over the wordpress port.

> and mantis installations now

I used to use Mantis but haven't in many years and we don't seem to have a port for it. If you'd like to contribute one please do.

> and learn where the mysql
> databases live inside the ports system


where $MYSQL is mysql5, mysql51, mysql55, percona or mariadb depending on which MySQL port you're using. Or you can change the data directory as desired by editing your my.cnf. I may be weird but on my development machine I keep my databases in $HOME/mysql/data.

> which is something I was very
> familiar using the Apple standard system. Importantly I need to learn
> how not to kill the databases during upgrades

The databases are not registered to any port so MacPorts will not touch them when you upgrade ports nor ever uninstall them.

When you upgrade MySQL, you may manually need to manually run the appropriate script to update databases to a new format.

More information about the macports-users mailing list