Is it possible from within a bash script to check if a mysql database exists. Depending on the result then perform another action or terminate the script?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Example script (Thanks to Bill Karwin for the
--userand--passwordcomment!):These are what the commands look like when run at a prompt:
If no DB exists, the output will look like this:
Then, parse the output and do what you need to based on if it exists or not!