Published in: SQL
1. Load Data from a csv file
2. Backing up a complete database
3. Backing up a specific table
4. Backing up multiple databases
5. Restoring a database
6. Setting up foreign keys between two databases
#Loading Data CSV into a general table LOAD DATA INFILE "/data.csv" INTO TABLE alldata FIELDS TERMINATED BY ","; #Backing up the complete database mysqldump -u [username] -p [password] [databasename] > [backupfile.sql] #Back Up specific tables. *Note: Multiple tables are seperated by a space. mysqldump -u [username] -p [password] [databasename] [table1 table2 etc] #Backing up multiple databases mysqldump -u [username] -p [password] --databases [databasename] > [backupfile.sql] #Restoring a Database mysql -u [username] -p [password] [database_to_restore] < [backupfile.sql] #Creating a username and password instead of using root GRANT ALL PRIVILEGES ON database_development.* TO 'chrisaiv'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; #Setting a foreign key between two databases UPDATE albums SET artist_id = 3 WHERE id = 6;
You need to login to post a comment.
