Tuesday, May 29, 2018

How can I run an SQL script in MySQL?

If you’re at the MySQL command line mysql> you have to declare the SQL file as source.
mysql> source \home\user\Desktop\test.sql;
 
You have quite a lot of options:
  • use the MySQL command line client: mysql -h hostname -u user database < path/to/test.sql
  • Install the MySQL GUI tools and open your SQL file, then execute it
  • Use phpmysql if the database is available via your webserver
 
 
you can execute mysql statements that have been written in a text file using the following command:
mysql -u yourusername -p"yourpassword" yourdatabase < text_file
 
 

No comments:

Post a Comment