Showing posts with label Snow Leopard. Show all posts
Showing posts with label Snow Leopard. Show all posts

May 20, 2010

Uninstall MySQL on Mac OS X (Leopard 10.5 or Snow Leopard 10.6)

Problem

You need to completely remove mysql from your system as easily as possible.

Symptoms

You want to do a clean delete and a fresh install because you don't want to deal with errors such as:
  • MySQL [your version] for Mac OS X can't be installed in this disk. A newer version of this software already exists on this disk.
  • [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  • [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

Solution

Execute the following commands that I found here and here:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
Maybe one day, if I'm feeling frisky, I'll come back and write a bash script to remove the MYSQLCOM line auto-magically. Maybe some magic involving sid or awk or something.

May 4, 2010

Install MySQL

I just referenced this section of a file on my laptop because it has direct links and I was too lazy to think through installing mysql. Then, I decided to post it so I can link to it from another post I'm writing. Enjoy.

Installation of MySQL v5.1

  1. Open the Safari browser then go to http://dev.mysql.com/downloads/mysql/5.1.html
  2. Download the latest version (today it's 5.1.46) either 32 or 64 bit (we use 32)
  3. Note: I recommend the DMG version, instead of the TAR archive because it has a handy pkg that, with one click, sets mysql server to run at startup.
    Snow Leopard (10.6):
    click the "Download" button under Mac OS X ver. 10.6 (x86, 32-bit), DMG Archive
    or
    Leopard (10.5):
    Mac OS X 10.5 (x86, 32-bit), Compressed DMG Archive
  4. On the next screen, you can ignore the login boxes by choosing

    "» No thanks, just take me to the downloads!"

    and select a mirror
  5. Double click on the mysql-5.1.46-osx10.6-x86.dmg file in the window opened by the download.
  6. Click the mysql-5.1.46-osx10.6-x86.pkg file to install mysql
  7. Optionally, once done, double click the "MySQLStartupItem.pkg" to automatically configure your Mac to launch the mysql server on startup
  8. Start the database by entering, /usr/local/mysql/bin/mysql –u root –p (no password needed).
  9. NOTE: if you get the error:
    “Can't connect to local MySQL server through socket '/tmp/mysql.sock'”
    Then, that means the mysql server is not running. One work-around to solve this problem is to enter a command similar to the following:
    sudo /usr/local/mysql/bin/mysqld_safe
    (enter your OS X login password, when prompted) Then, open a new terminal window and proceed
  10. List all databases by entering,
    SHOW DATABASES; 
  11. Create a new database,
    CREATE DATABASE myDatabase
  12. where myDatabase is the name of the new database.

  13. Use the database by entering, USE myDatabase
  14. Create a table in the new database by entering
    CREATE TABLE example_table (
             id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
             data VARCHAR(100),
             cur_timestamp TIMESTAMP(8)
           );
  15. Display the table by entering
    SHOW TABLES;
  16. Add a value to the table by entering
    INSERT INTO example_table (data) VALUES (‘the current time is’)
  17. View the all data in the table by entering
    SELECT * FROM example_table;
  18. In order to create users, enter
    CREATE USER ‘userBob’@’localhost’ INDENTIFIED BY ‘s3kr1tP4$$W0RD’;
  19. In order to grant permissions to users for local and remote connections to the database, enter
    GRANT ALL PRIVILEGES on myDatabase.* TO 'userBob'@’%’