CentOS-based Mysql learning Supplement 2-using Shell to create a database, centosmysql

Source: Internet
Author: User
Tags mysql commands

CentOS-based Mysql learning Supplement 2-using Shell to create a database, centosmysql

Article Source: CentOS-based Mysql learning Supplement 2-using Shell to create a database

For how to use the mysql database based on commands, see the "Instructions for using CentOS-based Mysql". This article only describes how to use the Shell script to create the database we want, the following is a Shell script for creating a database, which basically stores some mysql commands in the shell script.

#! /Bin/bash # Author: chisj # Time: 2015.7.22 # Describe: create Database # The username of mysql databaseUSER = "root" # The password of mysql databasePASS = "dragonwake" # The datebase name will be createdDATABASE = "SmartCare" mysql-u $ USER-p $ PASS <EOF>/dev/nullCREATE DATABASE $ DATABASEEOF

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

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.