Sunday, October 21, 2018

Import and Export Database using ssh




Import Database using ssh :- 

 mysql -u <database_username> -p -D <Your_databasename> < <database_path>  
 Example :-   
  mysql -u abcpanam_devuser -p -D abcpanam_abcpanama < abcdistr_abcpanama(1).sql 


Export Database using ssh :- 

 [abcdistr@server ~]$ mysqldump -u abcdistr_ntf -p abcdistr_abcpanama > abcdistr_abcpanama.sql 


IMPORT AND EXPORT DATABASE AT lOCALHOST USING TERMINAL

Connect Terminal to database

 $ mysql -h 127.0.0.1 -u root  
 $ /opt/lampp/bin/mysql -uroot -ppassword  
 ntf-22@NTF-22:/$ /opt/lampp/bin/mysql -uroot (IF THERE IS NO PASSWORD) 


IMPORT :-

ntf-22@NTF-22:~$ sudo /opt/lampp/bin/mysql>mysql -u root ssh_test_db < /home/ntf-22/Desktop/abcdistr_abcgrouptt.sql  
ntf-22@NTF-22:~$ sudo /opt/lampp/bin/mysql>mysql -u <database_username> <database_name> < <downloaded_database_sql_file_path_at_your_system>  

EXPORT:-

ntf-22@NTF-22:~$ /opt/lampp/bin/mysql>mysqldump -u root -p ABC_magento_db > ABC_magento_db.sql  
 ntf-22@NTF-22:~$ /opt/lampp/bin/mysql>mysqldump -u <database_username> -p <database_name> > <new_database_name.sql> 

No comments:
Write comments