Creating or moving a MySQL database
Unlike SQL Server, you cannot reliably move a MySQL database by moving the binary files in the MySQL directory. Instead, you should use the mysqldump utility.
Open a command line window to the MySQL bin directory and make sure both mysql and mysqldump binaries are both present. On Linux this location is likely /usr/local/mysql/bin and on Windows this is most likely C:\Program Files\MySQL\MySQL Server 5.0\
Dump the database using a command like this:./mysqldump --user=user --password=pw database_name_here > db.sql
Then connect using the MySQL command line client and create the database:./mysql --user=user --password=pw
create database new_database_name
use new_database_name
source db.sql
posted by Brian at 7/16/2008 02:36:00 PM | 0 Comments
Date formatting using MySQL
By default MySQL stores its dates in 'YYYY-MM-DD HH:MM:SS' format. When you have to integrate with .NET, it's nice to get the date in a format which is readable by DateTime.Parse().
In your SQL query, you can format the date by using the date_format function.SELECT date_format(YourDateHere, '%a %D %b %Y') FROM TableName;
Here are some example formatting strings and examples of their output (replace the formatting in the red part of the query above).
| Example | Format String |
| 1/28/2008 | '%c/%e/%Y' |
| 01/28/2008 | '%m/%d/%Y' |
| 1/28/2008 12:30 | '%c/%e/%Y %H:%i' |
| 01/28/2008 12:30 | '%m/%d/%Y %H:%i' |
| 1/28/2008 12:30:59 | '%c/%e/%Y %T' |
| 01/28/2008 12:30:59 | '%m/%d/%Y %T' |
posted by Brian at 5/22/2008 04:19:00 PM | 0 Comments