一、本地链接
1、查看MySQL密码
cat /usr/local/mysql/data/error.log 中的临时密码 mysql -uroot -p
2、修改root用户密码
mysql> alter user'root'@'localhost' identified by 'Welcome_1';
3、配置允许用户root远程登录
mysql>create user 'root'@'%' identified by 'Welcome_1'; mysql>grant all on *.* to 'root'@'%'; mysql>flush privileges;
二、远程链接
1、创建一个用户 user001 密码是Welcome_1
mysql>create user 'user001'@'%' identified by 'Welcome_1';
2、给 user001授权
mysql>grant all on mysql.* to 'user001'@'%'; mysql>flush privileges;
3、使用root用户查看系统的 user 表
mysql>user mysql; mysql>select host,user from user;
4、使用root用户查看系统的 db表
mysql>use mysql; mysql>select host,user,db from db where user='user001';