Running a MySQL script from MySQL Command Prompt on a Mac

I'm a complete newbie to SQL & MySQL. Installed MySQL on my MacBook running OS X 10.6.8. I can launch MySQL from Terminal. I can list the included databases using the "show databases;" command.

I am trying to install the sample files included with a book I'm using to learn MySQL (Ben Forta's MySQL Crash Course).

I would like to execute the two scripts to install the sample databases used as examples in this book. There are two script files, create.sql and populate.sql

I have copied both these files into /usr/local/mysql-5.1.73.osx10.6-x86_64/data folder, which is where I believe mysql stores the local databases.

When I try to run "use create.sql" from the mysql command line, I get an "ERROR 1049 (42000): Unknown database 'create.sql'

Please advise. Thanks in advance.
anuneznycAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan CraciunIT ConsultantCommented:
That message is correct. USE selects a database. And those are scripts, not databases.

To make your life way easier, get XAMPP for OSX from here: https://www.apachefriends.org/download.html

It comes with fully configured Apache, MySQL, PHP and other goodies.

Once you have those installed, you can use Phpmyadmin to run your sql scripts.

Ask if you need more help.

HTH,
Dan
0
Dave BaldwinFixer of ProblemsCommented:
After you are logged into 'mysql', use 'source create.sql' to run the SQL script.  More info here: http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anuneznycAuthor Commented:
Thank you, @Dave_Baldwin. That allowed me to run the script.
0
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.