MySQL (or these days, MariaDB) holds a lot of the data found on today’s web apps, and this data can be invaluable. Typically, web apps are made such that the important data is displayed in a useful and actionable way for the various users of the app. However, it’s not uncommon that a request may come in where you want the result of a specific query, something that isn’t available out of the box, and where you need to manually go in and run. To run a query in MySQL, you can do so by simply logging in from a console terminal using the app’s username, selecting your database, and inputting your SQL query like this: $ mysql --user=myapp -p > USE mydb; > SELECT * FROM mytable; The textbook way This is the most basic example of how to run a SELECT query. Of course, if you have millions of results, you may want to export them. This can be done using the INTO OUTFILE option. In order to properly have the above query saved in a CSV file so it can be opened in a spreads
Posts about technology, DevOps, the cloud and more.