Previous Page
19 MySQL tips for ROOT in Mac OS
  • 14 May 2010 16:35:32

These are some additional notes for running rdf on Mac OS. Please see my main page on rdf for more details, as well as my extra notes on rdf in Mac OS.

I do not use Mac OS anymore, so these instructions may need additional steps for Mac OS 10.6 and greater. That's not my problem, so don't email me about it, because I don't even have a system to test it on.

Old way sucks
#################################OLD JANKY WAY#######################################
Use fink to install mysql database manager.

$ fink install mysql

Create a startup script for mysql in /Library/StartupItems/

$ sudo daemonic enable mysql

Once daemonic has been run, you can also use the startup scripts to start mysql

$ sudo /Library/StartupItems/daemonic-mysql/daemonic-mysql start
#################################END OLD JANKY WAY#######################################

**************************NEW AND BETTER WAY**********************************
Go get the pre-compiled binaries for Mac OS 10.5 (or your version), otherwise you may be missing mysql_config command, either that, or maybe you needed like a path modification on fink. Why install through fink when you can get good binaries?

Go to the MySQL site and download the latest .dmg (package) for Mac OS X.

In the case you had it from fink, be sure to stop the fink version, and also uninstall the fink version, because there's no reason to keep it around anyway.

$ sudo /Library/StartupItems/daemonic-mysql/daemonic-mysql stop

$ fink remove mysql


Edit your path and add /usr/local/mysql/bin so you can use mysql_config

You can check to see if mysql is running on port 3306.

$ nmap -PN localhost

If you don't have the network mapper tool, you can use fink to get it

$ fink install nmap

And then try again

$ nmap -PN localhost

PORT STATE SERVICE
3306/tcp open mysql


Then you may log in to MySQL, specifying the root user, which is the only user setup by default. Note that this root user is unrelated to CERN's analysis package ROOT, and also unrelated to the root user of the *nix system.

$ mysql -u root

Then, once in mysql, you should set a password for root (replace MyNewPass with your preferred password)

mysql > UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';

mysql > FLUSH PRIVILEGES;


Now make a new user, with a password

mysql > GRANT ALL PRIVILEGES ON *.* TO 'crib'@'localhost' IDENTIFIED BY 'obakiller' WITH GRANT OPTION;

Now you may log out of mysql

mysql > quit

Re-login as crib

$ mysql -u crib -p

Enter the password 'obakiller'

View the default databases

mysql > SHOW databases;

Add a new database called 'crib'

mysql> CREATE database crib;

Confirm that there is now a database called 'crib'

mysql > SHOW databases;

Then you can log out.

mysql > quit

My only concern here is that I'd like to have mysql not started by default, but easily able to be started.

daid@dhcp49-162:StartupItems$ pwd
/Library/StartupItems


Move the MySQLCOM directory to the same location but hidden (to hopefully disable auto starting of MySQL, which is a port risk)

The actual daemon scripts is located:
/usr/local/mysql/support-files/mysql.server

So you can add this to your path, and add an alias to you profile, for example
mysqld="sudo mysql.server"

And then you may use
$ mysqld start
$ mysqld stop
$ mysqld restart


To toggle the server. Since I only really use MySQL for conversion of rdf->root for data, then I don't want mysql running all the time, or on boot.

        (__)               __(^^)              /   /    (__)      / PhD  \  (oO)     /|  /---^^---/     / | /| daid  ||    *  || ||------||
Next pageNext page