Domain, hosting, vps giá rẻ
Kết quả 1 đến 1 của 1

Chủ đề: [Linux] How to backup and restore MySQL databases on Linux

  1. #1
    nghiatichxanh1992's Avatar
    Bài viết
    5,038
    Cấp độ
    Bang hội
    Tiếu Ngạo
    Tu luyện
    Độ kiếp Hư Thần
    Giới tính
    Con trai
    Join Date
    Jun 2012
    Đến từ
    Hà Giang
    Tuổi
    31
    Danh vọng
    10
    Điện thoại
    0367790762

    [Linux] How to backup and restore MySQL databases on Linux

    How to backup and restore MySQL databases on Linux


    A simple and easy method for creating MySQL backups is to use the mysqldump command. This command will create a simple .sql file of an existing database, which can then be restored to any other empty MySQL database. This article will work for any Linux distribution running MySQL.


    1. Back up the database using the following command:

    mysqldump -u [username] –p[password] [database_name] > [dump_file.sql]
    Example: mysqldump -u root data112021 > data112021.sql

    The parameters of the said command as follows:

    [username] - A valid MySQL username.

    [password] - A valid MySQL password for the user.

    [database_name] - A valid Database name you want to take backup.

    [dump_file.sql] - The name of backup dump file you want to generate.


    2. Restore the backup to a local database server - the mysql command will let you take the contents of a .sql file backup, and restore it directly to a database. This is the syntax for the command:

    mysql -u [username] –p[password] [database_name] < [dump_file.sql]
    Example: mysql -u root data112021 < data112021.sql

    3. Restore the backup to a remote database server - you can also use the mysql command to restore a .sql file backup to a remote MySQL server. If you have another server running MySQL, and you have the database credentials, you can define a hostname in the command by adding the -h flag to specify a hostname. This changes the syntax of the command to:

    mysql –h [hostname] –u [username] –p[password] [database_name] < [dump_file.sql]
    Example: mysql –h -u root data112021 < data112021.sql

    As long as you have the correct credentials and the remote server is running, you will be able to restore the database remotely.
    Lần sửa cuối bởi nghiatichxanh1992, ngày 28/11/2021 lúc 3:05.
    Diễn đàn chia sẻ kiến thức điện thoại: http://chiase123.com
    Click vào Hiện ra để xem chữ ký của mình

Thông tin về chủ đề này

Users Browsing this Thread

Có 1 người đang xem chủ đề. (0 thành viên và 1 khách)

Các Chủ đề tương tự

  1. [Linux CentOS] How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6
    Bởi nghiatichxanh1992 trong diễn đàn VPS - Server
    Trả lời: 5
    Bài viết cuối: 09/01/2021, 23:38
  2. Change a Password for MySQL on Linux
    Bởi nghiatichxanh1992 trong diễn đàn VPS - Server
    Trả lời: 0
    Bài viết cuối: 23/02/2016, 21:26
  3. Hướng dẫn Backup/Restore (Sao lưu/Phục hồi) dữ liệu trên hosting
    Bởi nghiatichxanh1992 trong diễn đàn Hosting - Domain
    Trả lời: 0
    Bài viết cuối: 11/09/2015, 17:41
  4. [VPS Linux] Hướng dẫn cài đặt Apache, MySQL, PHP để chạy 1 trang web
    Bởi nghiatichxanh1992 trong diễn đàn VPS - Server
    Trả lời: 0
    Bài viết cuối: 04/02/2014, 23:48
  5. Trả lời: 0
    Bài viết cuối: 08/10/2013, 21:03

Tag của Chủ đề này

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •