I am in a mysql terminal and I created a user.
CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'identifier';
I tried to grant the user privileges with
GRANT INSERT ON *.* TO 'webuser'@'localhost';
And got the error:
Access denied for user 'eligooch'@'localhost' (using password: YES)
So I tried
sudo GRANT INSERT ON *.* TO 'webuser'@'localhost';
And got
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'sudo GRANT INSERT ON *.* TO 'webuser'@'localhost'' at line 1
So I am trying to grant privileges to a user but I am stuck.
Advertisement
Answer
Try this:
$ sudo mariadb -u root mysql -e "DROP USER 'webuser'@'localhost';" $ sudo mariadb -u root mysql -e "CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'Password123#%';" $ sudo mariadb -u root mysql -e "GRANT INSERT ON *.* TO 'webuser'@'localhost';" $ sudo mariadb -u root mysql -e "SELECT host, user, Select_priv, Insert_priv FROM mysql.user;" +-----------+---------+-------------+-------------+ | host | user | Select_priv | Insert_priv | +-----------+---------+-------------+-------------+ | localhost | root | Y | Y | | localhost | halley | Y | Y | | localhost | webuser | N | Y | +-----------+---------+-------------+-------------+
Make sure the password used for the user complies with the password policy