Creative Commons License
This blog by Tommy Tang is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

My github papge

Saturday, March 30, 2013

download data from UCSC database to local drive

I wanted to download UCSC refGene table to my local computer.
However, it looks like it is not possible to direct pull data from UCSC to a local host Database.
on linux command line, mysql --user=genome -A
SHOW Databases;
USE hg19;
SHOW tables like "%ref%";


| Tables_in_hg19 (%ref%) |
| kgXref                 |
| kgXrefOld5             |
| refFlat                |
| refGene                |
| refLink                |
| refSeqAli              |
| refSeqStatus           |
| refSeqSummary          |
8 rows in set (1.31 sec)

select * from refGene into outfile "/export.txt";
ERROR 1045 (28000): Access denied for user 'genome'@'%' (using password: NO)

I got this error, and I googled it found that
"The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected 

rows to a file. The file is created on the server host, so you must have 
the FILE privilege to use this syntax.

If you want to create the resulting file on some client host other than 
the server host, you cannot use SELECT ... INTO OUTFILE. In that case, you 
should instead use a command such as

mysql -e "SELECT ..." >  file_name 

to generate the file on the client host."

So, instead on linux command line, I typed :
mysql --user=genome hg19 -A -sre 'SELECT * from refGene' > ~/Desktop/refGene.hg19

and now it works!

1 comment:

  1. cheap jimmy choo uk, combining elegant style and cutting-edge technology, a variety of styles of cheap women jimmy choo slingback heel , the pointer walks between your exclusive taste style.