Import database without table data directly by Mysql

0

I need to import a very large database into Mysql. For phpmyadmin almost stopped the server. So I tried directly through Mysql using the command:

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

Ok, I was able to import, but with all the data of all the tables, but I would like to know if you have any way to import the database with only the tables, without the data. Is this possible?

    
asked by anonymous 20.01.2018 / 16:55

1 answer

0

So you have to separate the creation lines and insert lines into separate files, so when you want to import only the tables you import, for example the tables.sql file and vice versa

tables.sql:

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'));
    
20.01.2018 / 17:51