CentOS-based MySQL learning Supplement two--Create a database using the shell

Source: Internet
Author: User
Tags mysql commands

Article source: CentOS-based MySQL learning Supplement two--Create a database using the shell

The article, "How to use the MySQL database based on commands ," can be seen in the articles "description of the use of the CentOS-based MySQL", this article just describes how to use shell scripts to create the database we want, the following is the shell script I created the database, Basically, you put 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 would be createddatabase= "SmartCare" Mysql-u $USER-p$pass &L t;< EOF >/dev/nullcreate DATABASE $DATABASEEOF

Here are a few things to note

1. This problem may occur if you edit the above script under Windows and then execute it under Linux.


You can also see my workaround here, using the command Dos2unix to convert the Windows file format to the Linux (Unix) file format

#dos2unix filename

Of course, if you need your system to install the command, the default system is not installed, you can use Yum to install

#yum Install Dos2unix


Here is a copy of the Linux file format script

Shell create MySQL database

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

CentOS-based MySQL learning Supplement two--Create a database using the shell

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.