MySQL: Commands I wish I could remember Chris Mendez - 23 Mar 2008 Import CSV fileLOAD DATA INFILE "/data.csv" INTO TABLE alldata FIELDS TERMINATED BY ","; #Dump DB data to CSV file SELECT * INTO OUTFILE '/tmp/products.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM productsLoading Data CSV into a general tableBacking up a complete databasemysqldump -u [username] -p [password] [databasename] > [backupfile.sql] Backing up the complete databaseBacking up a specific tablemysqldump -u [username] -p [password] [databasename] [table1 table2 etc] Back Up specific tables. *Note: Multiple tables are seperated by a space.Backing up multiple databasesmysqldump -u [username] -p [password] --databases [databasename] > [backupfile.sql] Backing up multiple databasesRestoring a databasemysql -u [username] -p [password] [database_to_restore] < [backupfile.sql] Restoring a DatabaseSetting up foreign keys between two databases.update albums set artist_id = 3 where id = 6;Setting a foreign key between two databasesSet a Password for RootSET PASSWORD FOR root@localhost=PASSWORD('secretpassword');Set a Password for Root