Mac Mysql Client Library

13 3 likes 52,183 views Last modified Nov 24, 2013 4:14 PM

Apr 17, 2012  Was MySQL installed from MySQL binary packages? That could explain the path being missing from LDLIBRARYPATH Also, what was the output of mysql. May 03, 2017  I am unable to install mysqlclient on macOS anymore via pip. I'm on latest macOS, Python 3.6.1 and pip 9.0.1, within virtualenv. The installation ends with: Collecting mysqlclient Using cached mysqlclient-1.3.10.tar.gz Complete output fr.

This User Tip describes how to download, install, and setup MySQL for use on OS X. It includes an optional section for Perl support. Please read through the entire User Tip before starting.


Requirements:

  1. Basic understanding of Terminal.app and how to run command-line programs.
  2. Basic usage of vi. You can substitute nano if you want.

Optional:

Xcode (with command line tools) is required for the MySQL Perl driver.


Lines in bold are what you will have to type in at the Terminal.

Replace <your local host> with the name of your machine. Ideally, it should be a one-word name with no spaces or punctuation. It just makes life easier.

Replace <your short user name> with your short user name.


Download MySQL from a local mirror. You want the Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive. At the time of writing this User Tip, the current version is 5.5.34. By the time you read this, there may be a newer version to use instead. Open the archive mysql-5.5.34-osx10.6-x86_64.dmg.


Install only the mysql-5.5.34-osx10.6-x86_64.pkg package. Ignore everything else.


MySQL comes with a Preference Pane and Startup Item that are based on technologies that Apple deprecated years ago. If you install the Preference Pane or Startup Item, your MySQL installation could fail at some point in the future when Apple removes support for Startup Items. This was reported to MySQL a long time ago. Until MySQL gets around to fixing this bug, we will have to do it ourselves.


Create a launchd config file for MySQL:

sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist

How


Use the following content:

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>

<plist version='1.0'>

<dict>

<key>KeepAlive</key>

<true/>

<key>Label</key>

<string>com.mysql.mysqld</string>

<key>ProgramArguments</key>

<array>

<string>/usr/local/mysql/bin/mysqld_safe</string>

<string>--user=mysql</string>

</array>

</dict>

</plist>


(if you are new to vi, type 'i' to enter insert mode. Then ⌘-v to paste the above content. Press escape to get back to command mode. Then type 'ZZ' to save and exit.)


The default path for the MySQL socket is not appropriate for MacOS X. Until it is changed, MySQL will not be able to communicate with PHP should you choose to enable that. Let's fix this now.


Create a config file for MySQL that matches the Apple PHP build:

sudo vi /etc/my.cnf


Use the following content:

[client]

socket=/var/mysql/mysql.sock


[mysqld]

socket=/var/mysql/mysql.sock


Start MySQL:

sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist


MySQL is now up and running. Don't forget to set a root password and configure your users if this is all you need.


If you need to configure Perl support for MySQL, don't setup a root password just yet. Having no password will make testing the Perl module easier. Keep reading..

You will need Xcode and command line tools for this part.


Download the MySQL Perl driver.


Extract the archive with:

tar zxvf DBD-mysql-4.020.tar.gz


Move into the directory:

cd DBD-mysql-4.020


First, fix the MySQL client library. (credit)

Mac Mysql Client Library For Pc


For Lion, type:

sudo install_name_tool -id /usr/local/mysql-5.5.34-osx10.6-x86_64/lib/libmysqlclient.18.dylib /usr/local/mysql-5.5.34-osx10.6-x86_64/lib/libmysqlclient.18.dylib


Next, build DBD::mysql with:

perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config --testsocket=/var/mysql/mysql.sock --testuser=root

make

make test

sudo make install



Now you can set a root password and configure your users.

This chapter discusses MySQL Client Library Driver for Oracle Database, and its use in migrating applications from MySQL to Oracle.

This chapter contains the following topics:

See Also:

Chapter 7, 'API Reference for Oracle MySQL Client Library Driver' for more information about MySQL programmatic support

Introduction to MySQL Client Library Driver for Oracle

MySQL Client Library Driver for Oracle Database 12c Release 1, liboramysql, is a drop-in replacement for MySQL Commercial Connector/C 6.0 client library. The liboramysql driver implements a similar API, enabling C-based applications and tools developed for MySQL to connect to Oracle Database. The driver may be used to migrate applications from MySQL to Oracle Database with minimal changes to the application code.

The liboramysql driver uses Oracle Call Interface (OCI) to connect to Oracle Database.

Figure 6-1 MySQL Application Code Using liboramysql Driver to Connect to Oracle


Description of 'Figure 6-1 MySQL Application Code Using liboramysql Driver to Connect to Oracle'

The C code snippet in Example 6-1 demonstrates how to connect to MySQL and how to insert a row into a table. After updating the connection credentials, this code can run unchanged against Oracle Database when the executable is linked using the liboramysql library, instead of the libmysqlclient library.

Example 6-1 Connecting to MySQL and Inserting a New Row

Although the database schema and data must be migrated to Oracle separately, and although the liboramysql library does not translate SQL statements, considerable amount of effort is conserved when migrating to Oracle Database because no changes have to be made to the application code.

Custom C applications can use the liboramysql library to easily migrate to Oracle Database.

Installation and First Use of MySQL Client Library Driver for Oracle

The MySQL Client Library Driver for Oracle is provided as a file in the liboramysql.so shared library for Linux and as the oramysql.dll dynamic link library (DLL) for Windows. The driver is also packaged as part of the Oracle Instant Client Basic and Basic Lite packages for download from OTN. See http://www.oracle.com/technetwork/topics/linuxsoft-082809.html and http://www.oracle.com/technetwork/topics/winsoft-085727.html.

The driver must be installed in the same directory as the Oracle Client Shared Library, that is, libclntsh.so for Linux and oci.dll for Windows. Typically, you must set the operating system environment variable (LD_LIBRARY_PATH on Linux or PATH on Windows) to include this installation directory.

For ORACLE_HOME installations, the driver library is installed in the $ORACLE_HOME/lib directory for Linux and the %ORACLE_HOME%bin directory for Windows. For Instant Client ZIP files, the library is in the instantclient_12_1 directory. For Instant Client RPM installations, the library is in the /usr/lib/oracle/12.1/client/lib or /usr/lib/oracle/12.1/client64/lib directory on 32-bit and 64-bit Linux platforms, respectively.

Overview of Migration with MySQL Client Library Driver for Oracle

Migrating a C-based MySQL application to Oracle Database involves the following steps:

  1. Confirm that the application runs against MySQL Database.

    This ensures that the migration process starts at a known baseline of functionality.

  2. Replace thelibmysqlclientlibrary with theliboramysqllibrary.

    The application must be relinked to use the liboramysql library instead of the libmysqlclient library.

  3. Migrate the application schema to Oracle Database.

    The schema must be migrated to use Oracle DDL and types. Oracle SQL Developer assists in this process.

    See Oracle SQL Developer User's Guide for further details.

  4. Review all SQL statements used by the application.

    If necessary, change the SQL statements of the application to use Oracle syntax, or implement a SQL Translator to automatically perform the conversion at application run time. Rewrite any logic that depends on MySQL features that are not supported by Oracle Database.

    See Chapter 4, 'SQL Translation of JDBC and ODBC Applications'.

    Python imaging library mac. Mar 30, 2009.PIL: Python Imaging Library Thankfully, it’s not too hard to figure out the problems and get it built, installed and passing the tests. This post provides a few pointers to getting PIL working on OS X 10.5.6 with the Python 2.6 package and a bunch of libraries installed using Macports. How do I install Python Imaging Library on Mac OS X? Ask Question Asked 10 years, 7 months ago. Active 8 years, 8 months ago. Viewed 10k times 6. I'm an extremely amateur programmer; I've done some recreational algorithmics programming, but I honestly have no idea how libraries and programming languages really fit together. I'm supposed to.

  5. Update the connection string of the application to connect to Oracle Database.

    Use Oracle Easy Connect syntax or a tnsnames.ora connect identifier in the host parameter of the connection call.

  6. Test the application with Oracle Database.

    Verify the application against Oracle Database.

Using MySQL Client Library Driver for Oracle

The liboramysql API is compatible with MySQL Commercial Connector/C 6.0. MySQL Driver for Oracle Database, liboramysql, translates MySQL API calls to Oracle Call Interface (OCI) calls, and between Oracle and MySQL data types.

Existing MySQL-based applications may be relinked to use the liboramysql driver, making Oracle Database the new data source. Note that the liboramysql driver supports connections only to Oracle Database. Simultaneous connections to both MySQL Database and Oracle Database in the same application are not possible.

See Chapter 7, 'API Reference for Oracle MySQL Client Library Driver' for details on data type mapping and API compatibility. Additional information may also be found in Oracle SQL Developer User's Guide.

The liboramysql driver does not translate SQL statements. You must rewrite the statements that are not valid for Oracle Database. You can do this directly in the application, or by using a SQL Translator. The application schema and data must also be migrated separately. Oracle SQL Developer automates this process.

Whenever cross-version OCI connectivity exists for older versions of Oracle Database, you can use the liboramysql driver to connect to these older versions.

The following sections discusses these topics:

Relinking the Application with the liboramysql Driver

The fundamental step of using the liboramysql library is to relink the application to use the new library. The liboramysql library is compatible with the libmysqlclient.so library from MySQL Commercial Connector/C 6.0.2 package, so you must build and verify version-sensitive applications with MySQL Commercial Connector/C 6.0.2 before migrating to Oracle Database.

The installation scripts of public software compiled from source code typically expect MySQL components to follow a predefined system directory structure. You can use the setuporamysql.sh script in the demo directory of Instant Client SDK to achieve this.

Depending on the application, you can use one or more of the following ways to relink the application with the liboramysql library:

  • Build directly with theliboramysqllibrary.

    You can update your build scripts to use the liboramysql library and build custom applications directly with this Oracle library.

  • Use theliboramysqllibrary to emulate a MySQL Commercial Connector/C directory

    The setuporamysql.sh library in the Instant Client SDK shows how a directory structure emulating a MySQL Commercial Connector/C installation can be created. You may build applications using this emulated directory.

  • Use theLD_PRELOADenvironment variable.

    Preconfigured programs may be able to use the LD_PRELOAD environment variable to link with the liboramysql library. However, changing the value of this environment variable may not work if the program uses the dlopen() method.

  • Duplicate theliboramysqllibrary.

    Perform the following steps to rename the liboramysql library to the MySQL client library name used by the application:

    1. Use the ldd command to identify the MySQL library with which the application is linked:

    2. Create the following symbolic link as the Oracle software owner user:

    3. Add $ORACLE_HOME/lib to the LD_LIBRARY_PATH environment variable for any application that formerly used the libmysqlclient library:

  • Replace the system MySQL client library.

    Rename the target system MySQL client library and link the new library in its place. Because this option affects every application on the system that uses MySQL, and should be done only if absolutely necessary.

If MySQL applications are not rebuilt from the source code, then you must first link the applications against the libmysqlclient.so library from MySQL Commercial Connector/C 6.0.2 package. This ensures binary compatibility with the data structures in the liboramysql library.

Connecting to Oracle Database

To connect to Oracle Database with the liboramysql library, use Oracle Easy Connect syntax or a tnsnames.ora connect identifier in the host parameter of the connection call:

Supported Platforms

MySQL Client Library Driver for Oracle is available on platforms that support the Oracle Instant Client.

Mysql Client Software

See the list of supported platforms on the Oracle Support Certification site: https://support.oracle.com

Error Handling

All errors generated by OCI client code or the Oracle server are passed to the application when either the mysql_errno() method or the mysql_error() method is invoked after an error.

Globalization

The date format expected by the application may be set using NLS_DATE_FORMAT environment variable of Oracle Database, or changed with the equivalent ALTER SESSION command after connecting. The NLS_DATE_FORMAT environment variable is only used if NLS_LANG is also set in the environment.

Expected Differences

Mysql Client Mac Os X

Some APIs in the liboramysql library necessarily return different results because of the underlying differences between MySQL Database and Oracle Database. Existing applications that use these APIs may require logic changes. For details of these differences, see Chapter 7, 'API Reference for Oracle MySQL Client Library Driver'.