Monday, 9 July 2012

mysql misc - notes to self

installed mysql on mac
lazily running as root
needing to mkdir /var/run/mysqld and chmod 777 /var/run/mysqld
(missing something obviously)
Can across this useful document for installing mysql on mac after following my nose.

To connect to mysql using perl DBI/DBD

To load data into mysql

how to run an SQL command in a file from within mysql
mysql> source mysqlcmds.sql

how to run an SQL command from the command line
mysql < mysqlcmds.sql
(note can leave the if the first line in the mysqlcmds.sql file is use

Self consuming mysql sql script in shell script



mysql --user=myuser --password=xyz <
use mytest;

load data local infile '${MYFILE}'
into table mytest.mytable
character set UTF8
fields terminated by '|';


If you are getting the following error, it could be that you are missing the "local" keyword (if you are providing a full path to the file"

$ ./ 
ERROR 13 (HY000) at line 3: Can't get stat of '/mypath/myfile.dat' (Errcode: 13)

No comments: