Cutting a Table out of a mysqldump output file

I was restoring the backup of a MySQL 5.x server into MySQL 8.x server – and found out that it corrupt the MySQL 8.x ‘s mysql table

Which stores the usernames and passwords.

So I had to delete the mysql table from the backup, before trying to restore it again

Turn out it’s pretty easy, just will take some time since it’s a pretty big backup :

# search for beginning of 'mysql' table
cat backup.mysql | grep -n Current Database: `mysql`

# 155604:-- Current Database: `mysql`

# search for ending of 'mysql' table
tail -n +155604 backup.mysql | grep -n "Current Database"

# 1:  -- Current Database: `mysql`
# 916:-- Current Database: `phpmyadmin`

# cut that table out
head -155603 backup.mysql                > new.mysql
tail -n +$(( 155603+916 )) backup.mysql >> new.mysql

# voila !

13 thoughts on “Cutting a Table out of a mysqldump output file

  1. Great article. It is very useful and informative. Thanks a lot for sharing this post. – best tile store in chennai

  2. Awesome Blog! It’s a great spot to find new information. Thank you so much for this wonderful article. – shirdi flight packages from chennai

  3. Awesome Blog! It’s a great spot to find new information. Thank you so much for this wonderful article. – tile showroom in chennai

  4. Nice info. This is very impressive post, Very useful information, it clarified things a lot for us. Thanks for sharing valuable tips. – best tile store in chennai

  5. Terima kasih atas informasi yang diberikan.
    Izin kami beri informasi seputar mesin usaha untuk jualan bensin eceran.
    Mesin pom mini digital.
    Pengiriman ke seluruh Indonesia.
    Info : 082311159791
    Harga Pom Mini

Leave a Reply

Your email address will not be published. Required fields are marked *