Script to automatically generate and modify random root password for MySQL database

http://blog.csdn.net/yumushui/article/details/48007815
http://www.111cn.net/sys/linux/71228.htm

The role of EOF in shellhttps:
//zhidao.baidu.com/question /514989176.html

mysql---mysql -e detailed explanation

You can use shell script to operate MySQL database, and use mysql -e parameter to perform various SQL operations (create, delete, add, delete, modify, check) and other operations.
Usage
mysql -hhostname -Pport -uusername -ppassword -e sql statement related to mysql, you can operate mysql in the shell without running mysql at the mysql prompt.
Example:
#!/bin/bash

HOSTNAME="192.168.111.84" #Database information
PORT="3306"
USERNAME="root"
PASSWORD=""

DBNAME="test_db_test" #Database name
TABLENAME="test_table_test" #The name of the table in the database #Create



database
create_db_sql="create database IF NOT EXISTS ${DBNAME}"
mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${ PASSWORD} -e "${create_db_sql}"

http://blog.csdn.net/feeltouch/article/details/46643065

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326323899&siteId=291194637