Bash script to insert values in MySQL

后端 未结 5 894
别跟我提以往
别跟我提以往 2020-11-30 07:48

I want to make a bash script that connects to my MySQL server and inserts some valuse from a txt file. I have written this down:

#!/bin/bash
echo \"INSERT I         


        
5条回答
  •  情话喂你
    2020-11-30 08:32

    I use this and it works:

    mysql -uroot -proot < infile
    

    or select the database first

    ./mysql -uroot -proot db_name < infile
    

    or copy the whole SQL into the clipboard and paste it with

    pbpaste > temp_infile && mysql -uroot -proot < temp_infile && rm temp_infile
    

提交回复
热议问题