[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

MySQL import problem

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
lvollmer
Asked:
lvollmer
  • 8
  • 5
  • 4
  • +1
1 Solution
 
Aaron TomoskyTechnology ConsultantCommented:
Add ./ to the filename
0
 
Aaron TomoskyTechnology ConsultantCommented:
To clarify:
mysql -u root -p db < ./hp2.bz2
0
 
lvollmerAuthor Commented:
when i try that, i get > -bash: mysql: command not found

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Aaron TomoskyTechnology ConsultantCommented:
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
 
lvollmerAuthor Commented:
same thing > -bash: mysql: command not found
0
 
lvollmerAuthor Commented:
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
 
Aaron TomoskyTechnology ConsultantCommented:
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
 
Kevin CrossChief Technology OfficerCommented:
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
 
lvollmerAuthor Commented:
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
 
Kevin CrossChief Technology OfficerCommented:
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
 
lvollmerAuthor Commented:
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
 
lvollmerAuthor Commented:
what data file do you need me to look for?
0
 
Aaron TomoskyTechnology ConsultantCommented:
You moved it. I can see it right there in the ls results  It's not ./data/hp2.bz2
It's ./hp2.bz2
0
 
Kevin CrossChief Technology OfficerCommented:
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
 
lvollmerAuthor Commented:
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
 
Kevin CrossChief Technology OfficerCommented:
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
 
lvollmerAuthor Commented:
i will give this a shot, thanks
0
 
pete-mcpeteyCommented:
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 8
  • 5
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now