Import database without table data directly from Mysql

Asked

Viewed 518 times

1

I am needing to import into Mysql a very large database. By phpmyadmin almost stopped the server. Then I tried directly from Mysql using the command:

source /var/www/html/sistema/basedados.sql

Okay, I was able to import, but with all the data of all tables, but I would like to know if you have any way to import into Mysql the database only with the tables, without the data. That’s possible?

2 answers

1

At the time you export the database, you can choose to export only the database structure, i.e., it will not export any data, only the table structure.

Below is an image showing how to export only the structure by phpmyadmin, you go to export -> export method, click on custom, and then you disable the data field and just export. If the bank is not in phpmyadmin you should look for an option similar to this, which I believe should already be implemented.

inserir a descrição da imagem aqui

-1

Ai you have to separate the creation lines and the Insert in separate files, so when you want to import only the tables you import for example the.sql tables file and vice versa

sql tables.:

CREATE TABLE fulano(
    id INT PRIMARY KEY AUTO_INCREMENT,
    nome VARCHAR(100),
    email VARCHAR(150),
    senha CHAR(32)
);

insert sql.

INSERT INTO fulano(nome, email, senha) VALUES ('José',   
'[email protected]', MD5('jose123'));

INSERT INTO fulano(nome, email, senha) VALUES ('Maria', 
'[email protected]', MD5('maria321'));
  • Hi Anderson. Actually I want to avoid this, since the sql file is very large, with several tables and data. This would be very difficult to open the file and separate the tables from the data, which will not be used. I would like a solution directly by SQL.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.