Solved

MySQL import problem

Posted on 2011-09-15
18
406 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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