How can I populate a database from a sql file when I'm in the mysql console?
 LOAD DATA INFILE doesn't fit my problem. I want to populate the whole database, not only one table. mysql -u root -p database < file.sql won't work either. Because I cannot out of the mysql console.
            Asked
            
        
        
            Active
            
        
            Viewed 1,784 times
        
    1
            
            
         
    
    
        Brian Tompsett - 汤莱恩
        
- 5,753
- 72
- 57
- 129
 
    
    
        OrangeTux
        
- 11,142
- 7
- 48
- 73
- 
                    I don't think there's a way to do it from the `mysql` command. Can you use MySQL Workbench? It has import/export. – Barmar Mar 02 '13 at 10:55
- 
                    http://stackoverflow.com/questions/5152921/import-sql-file-from-mysql-console – Markus Mikkolainen Mar 02 '13 at 10:58
- 
                    @MarkusMikkolainen It's a dupplicated. I'm sorry. – OrangeTux Mar 02 '13 at 11:00
1 Answers
-1
            
            
        You want to bulk insert at commandline? Why not use mysqlimport
shell> mysqlimport [options] db_name textfile1 [textfile2 ...]
 
    
    
        Freddie Fabregas
        
- 1,162
- 1
- 7
- 17
- 
                    
- 
                    1I think I misunderstood you. You said "when I'm in the mysql console". What do you mean by "i cannot out of the mysql console"? – Freddie Fabregas Mar 02 '13 at 10:46
- 
                    Excactly that ;). When I'm `exit` the console closes, I do not return to a shell. It's Windows... – OrangeTux Mar 02 '13 at 10:49