Skip to content

Starting MySQL server

Preston Parry edited this page Feb 16, 2015 · 6 revisions
  1. which mysql or brew install mysql
  2. mysql.server stop
  3. mysql.server start
  4. mysql -u root logs in as the root user. adding in the -p flag will prompt for a password.
  5. create database dbname
  6. In Bash (not the mysql terminal), load your schema using mysql -u root dbname < server/schema.sql on the command line. again, the -u root part sets your username to root
  7. log into command line with mysql -u root 7a. show databases
  8. use dbname
  9. create table statement with the full table description
  10. describe table
  11. check to see if you have any sql 'modes' enabled: SELECT @@SESSION.sql_mode;
  12. if so, run SET SESSION sql_mode = '';
  13. load the data: load data infile '~/ghLocal/thesis-project/githubViz/201412export1.csv' into table raw_data_import character set latin1 fields terminated by ',' enclosed by '"' escaped by '\\' lines terminated by '\n' starting by '' ignore 1 lines; for more information on loading data: http://www.mysqltutorial.org/import-csv-file-mysql-table/
  14. If it's saying 0 rows affected, see what your newline characters are. Excel sometimes adds in an extra comma at the end of each line, at which point your newline character is ',\n'.
  15. if you get warnings, show warnings;
  16. cackle gleefully! then figure out what you've screwed up :)
  17. you may have lines in there from before when you were testing; if so: drop table tablename, and start again at step XX where we create the table.

For more information on the whole process: http://www.linux.org/threads/databases-with-linux.4222/

Clone this wiki locally