Create a database using Shell in CentOS

Source: Internet
Author: User

Create a database using Shell in CentOS

This article only describes how to use the Shell script to create the database we want. The Shell script for creating the database is provided below, which basically stores some mysql commands in the shell script.

[Plain] view plaincopy
  1. #! /Bin/bash
  2. # Author: chisj
  3. # Time: 2015.7.22
  4. # Describe: CreateDatabase
  5. # Theusernameofmysqldatabase
  6. USER = "root"
  7. # Thepasswordofmysqldatabase
  8. PASS = "dragonwake"
  9. # Thedatebasenamewillbecreated
  10. DATABASE = "SmartCare"
  11. Mysql-u $ USER-p $ PASS <EOF>/dev/null
  12. CREATEDATABASE $ DATABASE
  13. EOF

Several Notes

1. If the script is edited under windows and then executed under linux, this problem may occur.

You can also see the solution here. Use the command dos2unix to convert the windows file format to the linux (unix) file format.

# Dos2unix filename

Of course, the premise is that you need to install this command on your system. By default, this command is not installed on the system. You can use yum for installation.

# Yum install dos2unix

Here is a script in linux file format.

Create a mysql database using shell

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.