Is there anyway to do the same with prefix underscore with same username.
For example :-
#!/bin/bash
db_user=devdb
db_pass=`openssl rand -hex 16`
mysql -u root <<-EOF
CREATE USER '$db_user'@'localhost' IDENTIFIED BY '$db_pass';
GRANT ALL PRIVILEGES ON `$db_user\_%` . * TO '$db_user'@'localhost';
FLUSH PRIVILEGES;
EOF
In above script GRANT ALL PRIVILEGES giving error and i want solution for that.
If i am using below command without variables directory in mysql root then no error.
GRANT ALL PRIVILEGES ON `devdb\_%` . * TO 'devdb'@'localhost';
Please reply if anyone have solution to this.