计算机网络/计算机科学与应用/系统/运维/开发

MySQL8 本地链接与远程链接

一、本地链接

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


努力的意义,不在于一定会让你取得多大的成就,只是让你在平凡的日子里,活得比原来的那个自己更好一点。

评论

^