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

  • SEARCH
  • Home
  • 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 9069501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:26:41+00:00 2026-06-16T17:26:41+00:00

I am developing a large database schema that I desire to make available to

  • 0

I am developing a large database schema that I desire to make available to clients.

I am new to MySql database administration. How do I restore a .sql file of the schema so that it also resets ALL auto incremental id columns back to 0 or Null again.

I actually restored to a new schema name and inserted a test record and found the auto id columns were incrementing from where they left-off in the last schema name.

How do I address this in MySql database modeling?

I want to always be able to ‘spin-off’ an exact copy of my current version data model for a paying customer.

Thank you.

  • 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-06-16T17:26:43+00:00Added an answer on June 16, 2026 at 5:26 pm

    You can dump the schema only, without data this way:

    $ mysqldump -d databasename > databasename-schema.sql
    

    If you use InnoDB tables (which you should), the auto-increment value is always reset every time you restart the MySQL instance. The value it is reset to in each table is equal to the max value currently stored in the table, plus 1. So if your tables are empty, the value will be 1.

    If you don’t want to restart the MySQL instance after you restore, you can either strip the auto-increment clause in your CREATE TABLE statements before restoring:

    $ mysqldump -d databasename | sed -e 's/AUTO_INCREMENT=[0-9][0-9]*//' 
      > databasename-schema.sql
    

    Or else you can ALTER TABLE to reset the auto-increment value after restoring. This has to be done on a per-table basis, but you can query the list of tables that have auto-increment keys from the INFORMATION_SCHEMA:

    $ mysql -N -B -e "SELECT CONCAT('ALTER TABLE \`', table_schema, '\`.\`', 
      table_name, '\` AUTO_INCREMENT=1;') AS ddl FROM INFORMATION_SCHEMA.TABLES 
      WHERE table_schema = 'test' AND AUTO_INCREMENT IS NOT NULL" | mysql -v
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a PHP application that deals with a large MySQL database and
I am developing large data collecting ASP.Net/Windows service application-pair that uses Microsoft SQL Server
I'm developing a spring application that uses large MySQL tables. When loading large tables,
One of our teams is developing a database that will be somewhat large (~500GB)
I am developing a rather large database schema using Entity Framework Code First. I
I am developing an application that displays a large database of items. There is
My team is developing a large java application which extensively queries a MySQL database
I'm developing a web application based on ASP.NET MVC. There are a large database.
I'm currently developing a large site that handles user registrations. A social networking website
Right now I'm developing the prototype of a web application that aggregates large number

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.