I want to execute a command as root to grant privileges to a certain user to a certain "empty" database.
I have tried many attempts and cannot get the syntax to work:
mysql --host=localhost --user=root --password={root password} --execute="GRANT ALL PRIVILEGES ON `otft_oms_dev_userID-001.*` TO `otft_omsUser`@`localhost` IDENTIFIED BY `{user password}` WITH GRANT OPTION"
-bash: {part of user password}`: event not found
mysql --host=localhost --user=root --password={root password} --execute='GRANT ALL PRIVILEGES ON `otft_oms_dev_userID-001.*` TO `otft_omsUser`@`localhost` IDENTIFIED BY `{user password}` WITH GRANT OPTION'
ERROR 1046 (3D000) at line 1: No database selected
mysql --host=localhost --user=root --password={root password} --execute="GRANT ALL PRIVILEGES ON 'otft_oms_dev_userID-001.*' TO 'otft_omsUser'@'localhost' IDENTIFIED BY '{user password}' WITH GRANT OPTION"
-bash: {part of user password}`: event not found
mysql --host=localhost --user=root --password={root password} --execute="GRANT ALL PRIVILEGES ON 'otft_oms_dev_userID-001.*' TO 'otft_omsUser'@'localhost' WITH GRANT OPTION"
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''otft_oms_dev_userID-001.*' TO 'otft_omsUser'@'localhost' WITH GRANT OPTION' at line 1046
mysql --host=localhost --user=root --password={root password} --execute="GRANT ALL PRIVILEGES ON otft_oms_dev_userID-001.* TO 'otft_omsUser'@'localhost' WITH GRANT OPTION"
ERROR 1046 (3D000) at line 1: No database selected
mysql --host=localhost --user=root --password={root password} --execute="GRANT ALL PRIVILEGES ON `otft_oms_dev_userID-001.*` TO 'otft_omsUser'@'localhost' WITH GRANT OPTION"
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TO 'otft_omsUser'@'localhost' WITH GRANT OPTION' at line 1
use db_name;
otft_oms_dev_userID-001
@Arvind