![]() Pretty easy.īe warned, if you are executing a particularly large file that may take some time to complete, the command line is the best way to go, as phpMyAdmin is limited by the file upload size and is limited in how long it is allowed to execute tasks depending on the configuration of the web server it is running from. Press the go button when you’re ready to go. Navigate to the database you wish to execute the SQL commands within, then go to the import tab and browse for the file you wish to execute. It’s a good tool for those less comfortable working on the command line. If you use phpMyAdmin to administrate your MySQL server, you can also execute MySQL files from there. The > command directs the output of the command into the given results file. Mysql -host="mysql_server" -user="user_name" -database="database_name" -password="user_password" "path/to/sql/results.txt" You can also execute an SQL file without logging into MySQL from the Linux shell – this is especially useful if you wish to make your command part of a Bash/Shell script: mysql -host="mysql_server" -user="user_name" -database="database_name" -password="user_password" results_file The path should not be wrapped in quotes!.The file will need to be located on the same system on which the MySQL server is running or on a filesystem available to it. ![]() You should provide the full absolute path to the file you wish to read as it may not be clear what working directory will be from within MySQL.If you’re logged into the MySQL command line, you can use MySQL statements to execute the contents of a script/file using the source command: source full/path/to/sql/file.sql Most GUI database managers have a simple import option prominently displayed in the menu bar – so here’s how to do it from the command line (and PHPMyAdmin if you’re command-line averse). ![]() Whether you’re installing a package, following a tutorial, or restoring a backup – it’s useful to be able to execute an SQL script from a file and have it do all of the work for you, rather than having to type it all out. Here is an article outlining several methods for running SQL files in MySQL on Linux/Ubuntu.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |