如何将MysQL中的代码导出_如何使用命令提示导出MySQL数据库?

echo -e "Welcome to the import/export database utility\n"

echo -e "the default location of mysqldump file is: /opt/lampp/bin/mysqldump\n"

echo -e "the default location of mysql file is: /opt/lampp/bin/mysql\n"

read -p 'Would like you like to change the default location [y/n]: ' location_change

read -p "Please enter your username: " u_name

read -p 'Would you like to import or export a database: [import/export]: ' action

echo

mysqldump_location=/opt/lampp/bin/mysqldump

mysql_location=/opt/lampp/bin/mysql

if [ "$action" == "export" ]; then

if [ "$location_change" == "y" ]; then

read -p 'Give the location of mysqldump that you want to use: ' mysqldump_location

echo

else

echo -e "Using default location of mysqldump\n"

fi

read -p 'Give the name of database in which you would like to export: ' db_name

read -p 'Give the complete path of the .sql file in which you would like to export the database: ' sql_file

$mysqldump_location -u $u_name -p $db_name > $sql_file

elif [ "$action" == "import" ]; then

if [ "$location_change" == "y" ]; then

read -p 'Give the location of mysql that you want to use: ' mysql_location

echo

else

echo -e "Using default location of mysql\n"

fi

read -p 'Give the complete path of the .sql file you would like to import: ' sql_file

read -p 'Give the name of database in which to import this file: ' db_name

$mysql_location -u $u_name -p $db_name < $sql_file

else

echo "please select a valid command"

fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值