Working With MySQL User Privileges
Allow non localhost db user to connect
allow binding from other hosts other than localhost
vi /etc/mysql/my.cnf remove bind-address = 127.0.0.1
check and see the current privileges on hosts
mysql> use mysql; mysql> select * from user; see if there is host = localhost and user = root which will not allow non localhost to access
grant the user with % (all hosts)
mysql> GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '[password same as root@local e.g. 5678 # e.g. GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '5678'; mysql> (optional) delete from user where host = 'localhost' and user = 'root'; mysql> flush privileges;
Create a new user
create a user
mysql> CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass'; mysql> CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
grant all privileges
mysql> GRANT ALL ON *.* TO 'myuser'@'localhost'; mysql> GRANT ALL ON *.* TO 'myuser'@'%';
or grant just enough
mysql> GRANT DELETE,INSERT,SELECT,UPDATE on mydatabase.* TO 'myuser'@'localhost';
mysql> flush privileges;
to see the privileges
mysql> SHOW GRANTS FOR mysql;