I would like to make a bash script that will add a user to my user table in a MySQL database. I have a username as a script argument stored in the $ USERNAME variable, and I need to execute this query on a MySQL server:
INSERT INTO `user` VALUES ('$USERNAME', password)
I know how to execute sql file, but it will not help me when I have username in a variable. The only way I can think of is to execute a php file with GET values ββand execute the sql command in php. And I'm not sure what will work with php, as I think.
Is there a better way?
thanks
EDIT: After your helpful answers, I went with this command, which works:
mysql -ppassword --default-character-set=utf8 -e "INSERT INTO table VALUES (\" $USERNAME@ \",\"password\")" database
source share