Could someone share how to read a set of strings from terminal and insert them into MySQL in Ubuntu.
Kindly share a sample of code because i can be able to understand better.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!
If you are using shell scripting you can use the
-e
flag for the mysql command to directly run your query. So for instance if you wanted to grab the last line of your apache error log file and insert it into the fieldlogline
in a mysql table callederrorlog
on a database calledlogs
you could use the following:This is a very basic example and generally I would recommend doing some validation on the value before you insert it into your database and add some error handling but this should give you the general idea.
If you are using another language like perl or php you can use backticks around your command to execute it and return the result and then use the tools provided by the language you choose to handle your interaction with mysql.