Wednesday, March 7, 2012

MySQL tips for mysqladmin and mysql dump

Work on the website prime-exposure has halted for the time being. However, I have been working hard on some other projects that will be going live soon and will be much more impressive.

The purpose of this post is to lend a few gems of knowledge I have gained in my hours of trawling through stackoverflow and other forums, it's going to be brief and to the point and I'm afraid it's only for OS X (although other unix like operating systems will be similar):

mysqladmin


When I first downloaded and installed MySQL the tools in "/usr/local/mysql/bin" weren't working. When I tried to use them I got a "command not found error" from the terminal. Here is the complete dummies guide to fixing that problem, leave a comment if you want more help:

1. Open terminal.
2. type in "sudo nano /etc/paths" (not including the speech marks)
3. Enter your password (the one you use to log on to your computer NOT any MySQL passwords)
4. add "/usr/local/mysql/bin" (not including speech marks) to the end of the file so that it looks like this:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/mysql/bin

or similar, it doesn't matter if the others aren't there (for the pursose of this argument anyway)

5. Press Ctrl + O to save
6. Press enter
7. Press Ctrl + x to exit the nano editor
8. Quit the terminal
9. Restart it (open it again)
10. Type "cd /usr/local/mysql/bin" (yup, you guessed it, no speech marks)
11. All the tools (including mysqladmin) should be working, type mysqladmin and hit enter to check.

Generally, unless you have set your permissions such that you don't have to, you should type "sudo" (as in "sudo mysqladmin") before using the tools in this folder.

mysqldump


This is a handy tool for backing up or transporting your database(s).

The step that is missing from everywhere else is:
1. Open terminal
2. Type "cd /usr/local/mysql/bin"
3. Follow the instructions from the MySQL manual pages, I know they're almost impenetrable but it will do you good.

No comments:

Post a Comment