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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
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.