Import & Export database on Linux

Posted by

Import
mysql -u username -p password database_name < filename.sql
mysql -u username -p -h localhost < filename.sql

Export
mysqldump -u username -p password  –all-database > filename.sql

For an entire database:
mysqldump –all database_name > dump.txt
And then on your new database server (if it’s different):
mysqladmin create database_name
mysql database_name < dump.txt

For a single table only:
mysqldump –all database_name table_name > dump.txt
And then on your new database server (if it’s different):
mysql database_name < dump.txt

CREATE USER
CREATE USER ‘user1’@’localhost’ IDENTIFIED BY ‘pass1’;
GRANT ALL PRIVILEGES ON *.* TO ‘user1’@’localhost’ WITH GRANT OPTION;

DROP USER
DROP USER user@host;

View structure
describe test;

Add Column
alter table revokekeys add slot varchar;