Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5971809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:34:09+00:00 2026-05-22T20:34:09+00:00

I have a large database dump.sql file I am importing from the command line

  • 0

I have a large database dump.sql file I am importing from the command line in linux. The .sql dump creates a database named “database_name”. I want to import the database from this .sql file but I want to force it to a database with a different name, as the script currently overwrites “database_name” and “database_name” already exists and has data I can’t overwrite.

Is the best option to find and replace within the .sql file? What is the best method for that since the file is 50mb. I can’t simply file_get_contents() on that shiz? Can I?

Below are the lines I would have to replace in the .sql file:

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `database_name` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `database_name`;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:34:10+00:00Added an answer on May 22, 2026 at 8:34 pm

    You have to replace the database_name in the .sql file.

    You can do that from the shell with sed 's/database_name/new_database_name/' dumpFile.sql > newDumpFile.sql

    this is the correct answer to my question but was provided by ‘fab’ in the comments of another answer.

    NOTE: As @Diego pointed out in the comments, if the string ‘database_name’ shows up anywhere else in this .sql dump, it will be replaced there as well. You may want to view the contents of the .sql file using less file_name.sql and then be more explicit with your find/replace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large sql dump file ... with multiple CREATE TABLE and INSERT
I have to dump a large database over a network pipe that doesn't have
I have a large database of users (~200,000) that I'm transferring from a ASP.NET
I have to import a large mysql dump (up to 10G). However the sql
I have a fairly large SQL Server database; I'd like to pull 4 tables
I have a large database and would like to select table names that have
I have a large database of normalized order data that is becoming very slow
I have a large ADO.Net dataset and two database schemas (Oracle) with different constraints.
I have a database table with a large number of rows and one numeric
On a SQL Server 2000 system, I have a templog.ldf file that seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.