mysql tips     
MySQL

To create a database:
CREATE DATABASE name;

To create a user:
GRANT ALL PRIVILEGES ON dbname.* TO 'monty'@'localhost' IDENTIFIED BY 'password';

To reload grant tables:
mysqladmin reload -p

To set a password:
SET PASSWORD = PASSWORD('biscuit'); (for the user you're logged in as)
SET PASSWORD FOR 'jeffrey'@'%' = PASSWORD('biscuit');

Export a database:
mysqldump -u user -p -a > dump.sql

Import the database you exported:
mysql -u user -p < dump.sql

Move databases from one server to another
mysqldump -uroot -plocalrootpassword -a --databases database1 database2 database3 | ssh root@destinationserver.com "mysql -uroot -pdestinationrootpassword"

Search and replace text in fields:

UPDATE [table] SET [field] = replace( [field], "search_for", "replace_with" );

Backup live database:
/usr/local/bin/mysqldump -u root -ppassword --all-databases --skip-lock-tables

Updated Jun 14, 2010

Number of readers
home
about me
blog archives
- docs
acroread
firefox
java
linux
mysql
perl
rpm
shell
vim
win

entertainment
experiences
funny lists
humor
intellectual
interests
metafilter
music
opinions
photos
web designs
tools
software
webmaster help

Sign up
Enter your email address to be notified of new posts




Search the site







Random quote
(View all quotes)
"Change is inevitable, except from vending machines."










(?) Choose theme:  X X X X X X