sudo vi etc/mysql/my.cnf
(root用戶能夠不帶sudo)
[mysqld] skip-grant-tables
:wq
保存退出後重啓mysql:sudo service mysql restart
UPDATE mysql.user SET authentication_string=PASSWORD("123") WHERE user="root"; flush privileges;
CREATE USER 'user2'@'localhost' IDENTIFIED BY '123';
create database test;
grant all privileges on test.* to user2@'%' identified by '123';
flush privileges;
show grants for 'user2'@'%';