Create database from the command line or shell script

I am writing a shell script that to setup my server and I need to create a database as part of this process.  Its pretty easy to do.  You can create a database from the command line without logging in to mysql interactive mode.  Here is the code

>mysql -u root -pyourpassword -e “create database some_database_name;”

NOTE: when I pasted this into bash, I had to change the quotes.. I guess wordpress converts them to a different encoding

Retrying MySQL slave query after an error

I did something stupid today.  I was logged into my slave and thought I was logged into the master.  I altered a table and then realized I was on the wrong server.  So I logged into master and altered the same table.  This created an error when the slave tried to replicate, because the column in the table it was altering already existed.  So the replication could not continue.  I ran this command:

>SHOW SLAVE STATUS \G;

This showed me the error, so I went back and deleted the column on the slave so the alter statement on the slave would finish without error.  Then all you have to do is stop slave and then start slave

>STOP SLAVE;

>START SLAVE;

The slave should catch up to the master shortly.  NOTE TO SELF… make slave user read only.

su on Mac

I am fairly new to the Mac and I was trying to figure out how to become su when using the Mac terminal. Apparently Mac does not come with su enabled by default.  When I tried the command “su”, it prompted me for a password, but I don’t remember setting a password before.  So in order to get super user access, you have to set the password for root first.  All you need to do is issue this command and you will be able to “su”

>sudo passwd root

Enter your user account password and then enter the new root password twice.  After that issue the “su” command and enter the password you just created.  You have super user access now.