Solved

Store MySQL result in a variable

Posted on 2013-06-03
1
515 Views
Last Modified: 2013-06-03
How would I store the MySQL code below into a variable?

    mysql --host=localhost --user=root --password=admin table <<EOF 2 >> logfile.log
    insert into video (title, description, url_video, upload_date) 
    values('testing','default_description','$filename', '$date_field');
    EOF

Open in new window


I want the script to log MySQL errors to the logfile and need to result of the query to be stored as a variable so it can be used a few times later in the script.
0
Comment
Question by:ipconfig610
1 Comment
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39216302
VAR=$(
mysql --host=localhost --user=root --password=admin table <<EOF 2 >> logfile.log
insert into video (title, description, url_video, upload_date)
values('testing','default_description','$filename', '$date_field');
EOF
)

echo "$VAR"
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question