Tech memo to myself: MySQL server on my Mac

MySQL logoAs I am getting more in to doing github stuff and running my machine as a development test server, I have need to have MySQL database set up and running locally, and since it requires me starting the server up every time, I figured it won’t hurt to write down what I did to set up my development environment. And everytime I see the MySQL logo with that dolphin like fish, I think: “So Long, and Thanks for All the Fish.”

  1. Download DMG from mysql.com. I got “Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive” but here is a great source of finding out if your have 64-bit or 32-bit computer.
  2. Double clicked on mysql-5.5.XX-osx10.6-x86_64.pkg, follow instruction. ReadMe.txt file warned me of an error, but didn’t happen for me.
  3. following from ReadMe.txt:

    The Mac OS X PKG of MySQL installs itself into `/usr/local/mysql-VERSION’ and also installs a symbolic link,
    `/usr/local/mysql’, that points to the new location. If a directory named `/usr/local/mysql’ exists, it is renamed to
    `/usr/local/mysql.bak’ first. Additionally, the installer creates the grant tables in the `mysql’ database by executing `mysql_install_db’.

  4. Did the same with MySQLStartupItem.pkg. from the RedMe:

    If you want MySQL to start automatically during system startup, you also need to install the MySQL Startup Item. It is part of the Mac OS X installation disk images as a separate installation package. Simply double-click the `MySQLStartupItem.pkg’ icon and follow the instructions to install it. The Startup Item need be installed only once. There is no need to install it each time you upgrade the MySQL package later.

    The Startup Item for MySQL is installed into `/Library/StartupItems/MySQLCOM’. Startup Item installation adds a variable `MYSQLCOM=-YES-’ to the system configuration file `/etc/hostconfig’. If you want to disable the automatic startup of MySQL, simply change this variable to `MYSQLCOM=-NO-’.

  5. After the installation, you can start up MySQL by running the following commands in a terminal window. You must have administrator privileges to perform this task.
    If you have installed the Startup Item, use this command:

    shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
    (ENTER YOUR PASSWORD, IF NECESSARY)
    (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

    If you don’t use the Startup Item, enter the following command sequence:

    shell> cd /usr/local/mysql
    shell> sudo ./bin/mysqld_safe
    (ENTER YOUR PASSWORD, IF NECESSARY)
    (PRESS CONTROL-Z)
    shell> bg
    (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

    You should be able to connect to the MySQL server, for example, by running `/usr/local/mysql/bin/mysql’.

  6. So, I did sudo /Library/StartupItems/MySQLCOM/MySQLCOM start and got
    Starting MySQL database server
    Nice.
  7. You might want to add aliases to your shell’s resource file to make it easier to access commonly used programs such as `mysql’ and `mysqladmin’ from the command line. The syntax for `bash’ is:
    alias mysql=/usr/local/mysql/bin/mysql
    alias mysqladmin=/usr/local/mysql/bin/mysqladmin

    Done.

  8. Not sure but did it. Something to do with Dynamic Library Location Path.
    export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
  9. See if it is running. Log in as root:
    /usr/local/mysql/bin/mysql -u root
  10. Do your SQL commands here, and when done, just “exit.” Bye.

UPDATE: Or, you can just use MAMP. Comes with MyPHPAdmin built in.

This entry was posted in Linux, Mac, and LAMP Open Source, Tech, Gadget, and Computer, Web/Print Design and Dev. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Leave a Reply

  • Welcome to Daigo’s Daily Digital Diorama. I blog about... whatever that comes to my mind.
  • Change color

    Purple Red Green Blue No Style

  • Archives

  • Calendar

    August 2011
    M T W T F S S
    « Jul   Sep »
    1234567
    891011121314
    15161718192021
    22232425262728
    293031  
  • Categories