MySQL add user privilege

Linux config mysql

go to /etc/mysql/mysql.conf.d/

> vim mysqld.conf

command out

bind-address = 127.0.0.1

to

# bind-address = 127.0.0.1

 

get in mysql

$ mysql -u root -p  (-localhost)
Enter password:

if you want to create user fun with password love, and who can access the database from anywhere

> create user 'fun'@'%' identified by 'love'

then

> grant all privileges on *.* to 'fun'@'%' with grant option;

>flush privileges;

 

mysql> GRANT ALL ON . to root@’192.168.1.4′ IDENTIFIED BY ‘your-root-password’;