MySQL Documentation

Installation

N.B. This is a work in progress!!! do not follow these instructions until this caveat is removed!

I installed MySQL5, Connector/J, and the Python libraries for MySQL using mac ports (you will first need to make sure mac ports is installed):

sudo port install mysql5 +server

This installs MySQL and will output the following:

lorcan-coyles-macbook:~ lorcan$ sudo port install mysql5 +server
Password:
--->  Fetching mysql5
--->  Verifying checksum(s) for mysql5
--->  Extracting mysql5
--->  Configuring mysql5
--->  Building mysql5 with target all
--->  Staging mysql5 into destroot
--->  Creating launchd control script
###########################################################
# A startup item has been generated that will aid in
# starting mysql5 with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
###########################################################
--->  Installing mysql5 5.0.51a_0+server
******************************************************
* In order to setup the database, you might want to run
* sudo -u mysql mysql_install_db5
* if this is a new install
******************************************************
--->  Activating mysql5 5.0.51a_0+server

By executing the following MySQL will launch at startup:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

and by executing the following, MySQL will set up the necessary databases to get started (only do this step if this is a new install):

sudo -u mysql mysql_install_db5

This issues some recommendations as to how to secure the installation better. Execute the following command to do this, setting a root password, removing anonymous users, disabling root remote access, disabling the test database, and reloading the privileges tables (pay careful attention to your choices here, they will affect the way you interact with your database later):

/opt/local/lib/mysql5/bin/mysql_secure_installation

Now you should be ready to set up new tables and users with your root account.

Installing MySQL Libraries

To access your mysql database from Java and Python you should consider installing Connector/J and py-mysql respectively. You can use mac ports to do this:

sudo port install mysql-connector-java
sudo port install py-mysql

Troubleshooting

Another version of this port is already active

If you have not disabled any pre-existing versions of mysql you may get the following error when you try to install the new version:

--->  Activating mysql5 5.0.51a_0+server
Error: Target org.macports.activate returned: Image error: Another version of this port (mysql5 @5.0.51a_0) is already active.
Error: Status 1 encountered during processing.

To overcome this, simply deactivate the previous installation:

sudo port deactivate mysql5

and try to install it again.

mysql: command not found

When running /opt/local/lib/mysql5/bin/mysql_secure_installation, it may complete with the following error:

/opt/local/lib/mysql5/bin/mysql_secure_installation: line 42: mysql: command not found
 ... Failed!

If this is the case, your $PATH variable probably does not include the directory containing the symlinks for mysql5. These are contained in /opt/local/lib/mysql5/bin (these symlinks point to the mysql5 versions of the relevant commands). To update your path edit your .bash_profile file, adding the following lines:

# for mysql
export PATH=/opt/local/lib/mysql5/bin:$PATH

and update your $PATH variable:

source ~/.bash_profile

This should solve the problem :-)

Tutorial

public/mysql.txt · Last modified: 2008/09/04 08:46 by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki