Solved

MySQL import problem

Posted on 2011-09-15
18
401 Views
Last Modified: 2012-05-12
I have a file that i have to import to mysql via the terminal app in mac.

the file is called db.bz2 and resides in directory : mysql-5.5.15-osx10.6-x86

using the terminal app i cd into mysql-5.5.15-osx10.6-x86, then run this command:
mysql -u root -p db < hp2.bz2

but i get this error:
db.bz2: No such file or directory

when I do an ls i know I am in the directory and the file resides there - any idea what i am doing wrong?


0
Comment
Question by:lvollmer
  • 8
  • 5
  • 4
  • +1
18 Comments
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36543504
Add ./ to the filename
0
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36543521
To clarify:
mysql -u root -p db < ./hp2.bz2
0
 

Author Comment

by:lvollmer
ID: 36543703
when i try that, i get > -bash: mysql: command not found

0
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36543755
That means your mysql is not in the path. The easiest thin is to just use the full path of the mysql installation.

according to
http://dev.mysql.com/doc/refman/5.0/en/macosx-installation.html
By default it is at
/usr/local/mysql/
0
 

Author Comment

by:lvollmer
ID: 36543792
same thing > -bash: mysql: command not found
0
 

Author Comment

by:lvollmer
ID: 36543896
when i ls the /usr/local/mysql/ dir

here are the files

COPYING            bin            hp2.bz2            man            share
INSTALL-BINARY      data            include            mysql-test      sql-bench
README            docs            lib            scripts            support-files


the db file is in there for sure.
0
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36544077
I don't have a Mac in front of me at the moment so I'm not really any more help. I think it's something like this from the folder with the db:
/Usr/local/mysql/mysql -u root -p db < ./hp2.bz2
0
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 36544116
The mysql command is probably under bin so please credit aarontomosky for directing you correctly, but think it should be:

/usr/local/mysql/bin/mysql -u root -p db < ./hp2.bz2

Open in new window


This would be if you are running "from the folder with the db," i.e., /usr/local/mysql/data. If you first:

cd /usr/local/mysql/

Open in new window


Then:
./bin/mysql -u root -p db < ./data/hp2.bz2

Open in new window


See if one of those options works for you.
0
 

Author Comment

by:lvollmer
ID: 36544271
mwvisa1

 I had to move the file to this directory > /Applications/XAMPP/xamppfiles/var/mysql

this is where the active mysql is. how can i modify your cmd for this?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36544368
Where is the data file in relation to that directory? If structure is similar to what you showed before, then you can simply use a different CD command:

cd /Applications/XAMPP/xamppfiles/var/mysql/

Open in new window


MySQL command is likely still under bin and database is likely still under data. Just guesses, though, so correct those for your proper data directory/file location.

./bin/mysql -u root -p db < ./data/hp2.bz2

Open in new window

0
 

Author Comment

by:lvollmer
ID: 36544576
still getting -bash: ./data/hp2.bz2: No such file or directory

when i ls /Applications/XAMPP/xamppfiles/var/mysql

I get:

ib_logfile1
cdcol                        ibdata1
devmac.err                  l@002dhp
houseparty2                  mysql
l_lab                  mysql.sock
l_lab_test            surveys
                  test
hp2                        testapp
hp2.bz2

so I know the file is in that directory
0
 

Author Comment

by:lvollmer
ID: 36544593
what data file do you need me to look for?
0
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36544631
You moved it. I can see it right there in the ls results  It's not ./data/hp2.bz2
It's ./hp2.bz2
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36545037
I agree. Your mysql command is there too, so no bin. Run it as shown here: http:#a36543521 (after changing directories to /Applications/XAMPP/xamppfiles/var/mysql )
0
 

Author Comment

by:lvollmer
ID: 36545204
so to clarify I am doing this:

cd /Applications/XAMPP/xamppfiles/var/mysql

followed by this:

mysql -u root -p db < ./hp2.bz2

Because when I do that, I still get this error:
-bash: mysql: command not found
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36545866
Wish I had a Mac handy also. See if this helps: http://dev.mysql.com/doc/refman/5.0/en/macosx-installation.html -- shows how to alias path to mysql. Other recommendation in the document is as was suggested, which is add to your path. It shows calls using sudo also, so you can try:

sudo mysql -u root -p db < ./hp2.bz2

But you may still need to alias mysql. The examples all show /usr/local/mysql/bin/mysql, so not sure if some remnants of the application are there even though you moved others.
0
 

Author Comment

by:lvollmer
ID: 36549230
i will give this a shot, thanks
0
 
LVL 3

Expert Comment

by:pete-mcpetey
ID: 37819346
Plain Text for Import.
First issue is that you are using a bz2 file. If this is a compressed file, it won't work. You need it to be in standard text for MySQL to import it.
Check if this is a text file or binary (compressed) file:
head ./hp2.bz2

Open in new window

If this doesn't work, try this command to extract it
bunzip2 ./hp2.bz2

Open in new window

You can use other commands but might want to just use a graphic one:
http://www.macupdate.com/app/mac/14503/gui-tar
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now