• About Us
  • Privacy & Policy
HowTo's
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
  • Home
  • Commands
  • Linux
  • SCM
  • Git
  • Database
  • MySQL
  • Kubernetes
  • Docker
No Result
View All Result
HowTo's
No Result
View All Result
Home Database

Dumping BLOBs in Hexadecimal Format with mysqldump

June 22, 2024
in Database, Database Commands Examples, Database Commands Tutorial, Database Tutorial, MySQL, MySQL Commands, MySQL Commands Examples, MySQL Tutorial
A A
0
14
SHARES
125
VIEWS
Share on FacebookShare on Twitter

The mysqldump command in MySQL is used for creating backups of databases. One of the options available is --hex-blob, which specifies that binary large objects (BLOBs) should be dumped in hexadecimal format rather than binary format. This can be particularly useful when you need to examine or transfer BLOB data in a human-readable format.

Here are several examples demonstrating the usage of --hex-blob:

Example 1: Dumping a single table named mytable with BLOB columns in hexadecimal format:

    mysqldump --hex-blob -u username -p mydatabase mytable > mytable_backup.sql
    

This command exports the table mytable from database mydatabase into a file mytable_backup.sql, converting BLOBs to hexadecimal format.

Example 2: Dumping an entire database mydatabase with all BLOBs in hexadecimal format:

    mysqldump --hex-blob -u username -p mydatabase > mydatabase_backup.sql
    

Here, all tables within mydatabase will be dumped into mydatabase_backup.sql, with BLOBs converted to hexadecimal.

Example 3: Dumping and restoring a database with BLOBs in hexadecimal format:

    mysqldump --hex-blob -u username -p mydatabase > mydatabase_backup.sql
    mysql -u username -p mydatabase_restored < mydatabase_backup.sql
    

This pair of commands first dumps the database into a file and then restores it, preserving BLOBs in hexadecimal format throughout.

Example 4: Dumping a specific table with BLOB columns in hexadecimal format and compressing the output:

    mysqldump --hex-blob -u username -p --compress mydatabase mytable | gzip > mytable_backup.sql.gz
    

Here, the output is compressed using gzip after converting BLOBs to hexadecimal.

Example 5: Dumping a database, excluding certain tables, with BLOBs in hexadecimal format:

    mysqldump --hex-blob -u username -p --ignore-table=mydatabase.table1 --ignore-table=mydatabase.table2 mydatabase > mydatabase_backup.sql
    

This command excludes table1 and table2 from the dump while converting BLOBs to hexadecimal.

Example 6: Dumping a database with specific character set and collation settings, including BLOBs in hexadecimal:

    mysqldump --hex-blob -u username -p --default-character-set=utf8mb4 --default-collation=utf8mb4_unicode_ci mydatabase > mydatabase_backup.sql
    

Setting character set and collation ensures compatibility while keeping BLOBs in hexadecimal format.

Example 7: Dumping and importing a database with BLOBs in hexadecimal format using named pipes:

    mysqldump --hex-blob -u username -p mydatabase | mysql -u username -p mydatabase_restored
    

Named pipes can be used to stream the dump directly to the import process, maintaining BLOBs in hexadecimal.

Example 8: Dumping and exporting a specific table with BLOBs in hexadecimal format to a remote server:

    mysqldump --hex-blob -u username -p mydatabase mytable | ssh user@remote-server 'mysql -u username -p mydatabase'
    

This command securely transfers the dump to a remote server while preserving BLOBs in hexadecimal format.

Example 9: Dumping a database with BLOBs in hexadecimal format and specifying a specific storage engine:

    mysqldump --hex-blob -u username -p --single-transaction --default-storage-engine=InnoDB mydatabase > mydatabase_backup.sql
    

Using --single-transaction ensures a consistent snapshot while converting BLOBs to hexadecimal.

Example 10: Dumping a database with BLOBs in hexadecimal format and excluding triggers:

    mysqldump --hex-blob -u username -p --skip-triggers mydatabase > mydatabase_backup.sql
    

Excluding triggers can be useful when restoring databases with BLOBs in hexadecimal format.

To verify whether the --hex-blob option was applied correctly, you can open the resulting SQL dump file using a text editor or a command-line viewer. Look for BLOB columns within the file to ensure they are represented in hexadecimal format, typically indicated by sequences of hexadecimal digits (0-9, A-F).

Also check similar articles.

Forcing mysqldump Execution Even on Errors
Emitting FLUSH PRIVILEGES Statement in mysqldump
Flushing Logs Before Dumping with mysqldump
Escaping Fields in mysqldump Output
Optionally Enclosing Fields in mysqldump Output

Tags: DatabaseDatabase Commands ExamplesDatabase Commands TutorialDatabase TutorialMySQLMySQL CommandsMySQL Commands ExamplesMySQL Tutorial
Previous Post

Forcing mysqldump Execution Even on Errors

Next Post

Connecting to MySQL Host in mysqldump

Related You may like!

howto

Overriding –databases Option in mysqldump

June 22, 2024
howto

Creating Tab-Separated Output Files with mysqldump

June 22, 2024

Handling Failed SSL Session Data Reuse in mysqldump

June 22, 2024

Setting SSL Session Data File in mysqldump

June 22, 2024

Setting TLS 1.3 Cipher in mysqldump

June 22, 2024

Configuring SSL FIPS Mode in mysqldump (OpenSSL Only)

June 22, 2024
Next Post
howto

Connecting to MySQL Host in mysqldump

howto

Ignoring Errors During mysqldump

howto

Ignoring Tables During mysqldump

Discussion about this post

Latest Updated

howto

How to Use -iname for Case-Insensitive Filename Searches in find

August 21, 2024
howto

Search for Files with Case-Insensitive Pattern Matching Using -ilname in find

August 21, 2024
howto

Find Files by Group Name with -group in find Command

August 21, 2024
howto

Locate Files by Group ID Using -gid in find Command

August 21, 2024
howto

How to Search for Filesystems with -fstype in find Command

August 21, 2024

Trending in Week

  • howto

    Using BTRFS Subvolume for User Home Directory in Linux

    22 shares
    Share 9 Tweet 6
  • Downloading Docker Images from a Registry

    13 shares
    Share 5 Tweet 3
  • Configuring SSL Connection Mode in mysqldump

    17 shares
    Share 7 Tweet 4
  • Omit Tablespace Information in mysqldump Output

    13 shares
    Share 5 Tweet 3
  • Setting MySQL Dump Compatibility Mode

    18 shares
    Share 7 Tweet 5
  • Setting Network Buffer Length in mysqldump

    13 shares
    Share 5 Tweet 3
  • Logging out from Docker Registries

    13 shares
    Share 5 Tweet 3
  • Scheduling Nodes in Kubernetes with kubectl uncordon

    12 shares
    Share 5 Tweet 3
  • Managing Default User Creation Settings in Linux

    15 shares
    Share 6 Tweet 4
  • Using Extended INSERT Syntax in mysqldump

    12 shares
    Share 5 Tweet 3
  • About Us
  • Privacy & Policy

© 2024 All Rights Reserved. Howto.swebtools.com.

No Result
View All Result

© 2024 All Rights Reserved. Howto.swebtools.com.