Hướng dẫn copy database bằng command line

Start mysql using the command
/opt/lampp/bin/mysql -u root
link: https://askubuntu.com/questions/95241/how-do-i-start-the-mysql-console-in-xampp
example: sudo /opt/lampp/lampp startmysql
and find path of mysql , it will be placed in bin directory of lampp, then login
example: /opt/lampp/bin/mysql -u root
Chú ý: Nếu sử dụng tham số -p khi bạn có đặt mật khẩu.
Ví dụ: /opt/lampp/bin/mysql -u root -p
Đã thực hành:
<!-- mysql -u root -p cái này dùng global thì chạy còn không thì bạn phải sử dụng lệnh sau -->
  /opt/lampp/bin/mysql -u root
  ls
  /opt/lampp/bin/mysql -u root -p tintuc_shopdunk < tintuc.backup.sql 
  Tuong tự:
  Export database
  /opt/lampp/bin/mysqldump --user=root --password="" bitnami_wordpress > bitnami_wordpress.sql
  Export all databases
  /opt/lampp/bin/mysqldump --user=root --password="" --all-databases  > all.sql

https://stackoverflow.com/questions/4546778/how-can-i-import-a-database-with-mysql-from-terminal

Assuming you're on a Linux or Windows console:

Prompt for password:

mysql -u <username> -p <databasename> < <filename.sql>
Enter password directly (not secure):

mysql -u <username> -p<PlainPassword> <databasename> < <filename.sql>
Example:

mysql -u root -p wp_users < wp_users.sql

mysql -u root -pPassword123 wp_users < wp_users.sql

Last updated