?
Solved

MySQL import problem

Posted on 2011-09-15
18
Medium Priority
?
415 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 40

Expert Comment

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

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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
LVL 40

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 40

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 61

Accepted Solution

by:
Kevin Cross earned 2000 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
 
LVL 61

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 40

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 61

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 61

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

590 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