how to run sql query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mandargholap
    New Member
    • Sep 2008
    • 1

    how to run sql query

    Hi,

    I have a simple .sql file which will create a database in mySQL.
    pl. help me to run this .sql file from vb6 program with shell command.

    Also tell me, how to add a username and password in the Shell command.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    You should be able to execute a shell command like so:
    Code:
    mysql -u userName -p < /path/to/file.sql
    Which should execute the SQL commands in that .sql file as that user.

    This would prompt you for a password tho. Not sure how you would handle that in VB.

    Comment

    • Marjeta
      New Member
      • Sep 2008
      • 25

      #3
      Here's how I run it:
      mysql --host=<hostname> --socket=<socket> -u <user> -p<password> <databasename > < <script>

      or, an example
      mysql --host=localhost --socket=/var/lib/mysql.sock -u myuser -pmypass mydb < test.sql

      Note: there's no space between -p and the password.

      Comment

      Working...