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'@'%';