I am trying to change user password using a shell script as below
#!/bin/bash
mysql.server start
mysql -u root << EOF
SET PASSWORD FOR root@'localhost' = PASSWORD(‘admin’);
EOF
But I am getting below error:-
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 '‘admin’)' at line 1
Instead of SET PASSSWORD command if use something else will work like if I use 'create database databasename' will works.
.
Update1:
If I use "admin" or 'admin' instead of ‘admin’, I got below error.
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 '“admin2”)' at line 1
.
Update2:
When using -e flag I got below error
./mysql.sh: line 3: syntax error near unexpected token
(' ./mysql.sh: line 3:mysql -u root -padmin -e “SET PASSWORD FOR root@'localhost' = PASSWORD(‘admin2’);”'
‘admin’can you wrap in these quotes? Try"admin"or'admin'instead