Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 60

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 66

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 72

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 76

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 56

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 578

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 585

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 606

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 613

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 620

Warning: Cannot modify header information - headers already sent by (output started at /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php:545) in /srv/sidawson.com/public/htdocs/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 1544

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/core.php on line 1092
Si Dawson . Com » Blog Archive » OSX MySQL DYLD_LIBRARY_PATH libmysqlclient.18.dylib – fix

OSX MySQL DYLD_LIBRARY_PATH libmysqlclient.18.dylib – fix

For some reason, the OSX version of MySQL can’t find its own libraries.

If you’re trying to connect to MySQL from code (in this case, Python, and the MySQLdb library), you’ll typically see something like this:

Traceback (most recent call last):
File “demo.py”, line 3, in <module>
import MySQLdb

File “/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/MySQLdb/__init__.py”, line 19, in <module>
import _mysql

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib

Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/_mysql.so

Reason: image not found

Which basically translates to “Duh, I can’t find myself.”

Specifically, it’s looking for the file libmysqlclient.18.dylib in /usr/lib, and not finding it – why? Because it installed it in /usr/local/mysql/lib. It’s been broken a few years.

Yay open source!

Anyway, there are several fixes out there, with varying levels of crapness.

The standard recommendation is to put this in your .bashrc (or .bash_profile) in your home dir:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib

Which fixes the problem, except then every time you try to run anything that isn’t MySQL related from the command line, you get a stupid message like this:

si@home:~$ su
dyld: DYLD_ environment variables being ignored because main executable…
(/usr/bin/su) is setuid or setgid
Password:

This gets old and boring verrrrry quickly.

Another suggestion is to put the export statement at the start of any script that uses MySQL, followed by an equivalent unset command at the end (so you’re not polluting the environment).

Now, have a quick think about how many different places you’d have to put this in (ie, any script or code that connects, accesses or uses any code at all that talks to MySQL). BORING.

After I’d edited 5 or 6 scripts I decided “ok, this is crap, there must be a better way.”

So, what’s the cleanest solution? Specifically, one that avoids having to alter everything you ever write, just to get around a (hopefully soon fixed) bug in the MySQL installation?

Do this:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

In other words, create a link from /usr/local/mysql/lib (actual location) to /usr/lib (the place MySQL goes looking).

No coding around the bug, no spurious and/or dangerous environment variables. Simple, clean, with minimal or zero side effects.


[update: It’s been further suggested, by Gary Allen Vollink, below, that linking to /usr/local/lib might be more upgrade friendly – and thus safer – than /usr/lib. Please read his comments. I’m inclined to agree]

related

  • No Related Posts

September 7th, 2013 | Bugs |
Mastodon