Because this is a blog for notes and I’m forgetful. Here’s some SQL things:
1. Connecting to a remote mySQL server over ssh: (source)
ssh -L 3306:localhost:3306 raccoon@raccoonstar.com
Now you can use MySQL Workbench instead of just a command line! woo!
2. Now, to import my CSVs… Make the database
create database testdb;
Then create the table… (After stealing Shamiq’s cleverness and using find-replace to steal the first line of the CSV and replace with varchar(255s…))
create table TableNameWoo (
column1 varchar(255),
column2 varchar(255),
column3 varchar(255));
Now that your table exists, import dat CSV~
LOAD DATA LOCAL INFILE '~/csvs/filename.csv'
INTO TABLE testdb.TableNameWoo FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
mySQL then yelled at me: ERROR 1148 (42000): The used command is not allowed with this MySQL version
Google then revealed that I needed to start mysql with “–local-infile”, which worked! (Though I’m not sure why)ˇ
Now you have a table with your CSV in it! Woo. :D