How to run mysql command on bash?

后端 未结 3 1409
南方客
南方客 2021-02-01 00:15

The following code works on the command line

mysql --user=\'myusername\' --password=\'mypassword\' --database=\'mydatabase\' --execute=\'DROP DATABASE myusername         


        
3条回答
  •  梦毁少年i
    2021-02-01 01:01

    This one worked, double quotes when $user and $password are outside single quotes. Single quotes when inside a single quote statement.

    mysql --user="$user" --password="$password" --database="$user" --execute='DROP DATABASE '$user'; CREATE DATABASE '$user';'
    

提交回复
热议问题