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