How to run a sql script sql script on mysql5

Bradley Giesbrecht pixilla at macports.org
Thu Apr 5 10:18:12 PDT 2012


On Apr 5, 2012, at 9:21 AM, Michael Parson wrote:

> On Wed, 4 Apr 2012, Michael Parchet wrote:
> 
>> I have install the mysql5 port. I do a secure installation whith only the root user and a password.
>> So noe I wold like to run a sql script to create a database.
>> I have tried the following command but this last has no effect
>> sudo  mysql5 -u root -p password script.sql
>> Can you help me please ?
> 
> Close, but try this:
> sudo mysql5 -u root -p password < script.sql

If "script.sql" does not "create/use" a database you may need to add the database to the command.

$ mysql5 -uroot -p -e "create database if not exists dbname;"
$ mysql5 -uroot -p dbname < script.sql


Regards,
Bradley Giesbrecht (pixilla)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2763 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macports-users/attachments/20120405/93ec5aaa/attachment.bin>


More information about the macports-users mailing list