zl程序教程

您现在的位置是:首页 >  其他

当前栏目

centos 7 安装查看并修改密码的命令操作方式

2023-03-15 22:02:20 时间

centos 7 安装查看并修改密码的命令操作方式

1 mysql安装后会生成一个默认密码,此密码登录后要修改密码,不能用于其他操作

cat /var/log/mysqld.log

2 登录root账号修改初始密码,复制上面的密码登录

mysql -u root -p

修改密码,注意密码要稍微复杂点(大小写+符号+数字),不然会提示 Your password does not satisfy the current policy requirements

ALTER USER USER() IDENTIFIED BY '密码';

配置远程访问

1 查下系统用户,root默认是不允许远程访问的,需要把下图root账户的localhost改成%

use mysql;
select user,host,plugin,authentication_string from mysql.user;
select user,host,plugin from mysql.user;

2 修改root的权限并刷新权限

update mysql.user set host='%' where user='root';
flush privileges;

新建mysql账号 + 授权

1 新建test账号,%表示允许远程登录 ,改成ip就是ip登录

create user 'test'@'%' identified by '账号';

下面是是授权部分: 2 给test用户授予testdb数据库的所有权限(可远程登陆)

grant all privileges on testdb.* to 'test'@'%';
flush privileges;

3 给test用户授予testdb数据库的查询权限(可远程登陆)

grant select on testdb.* to 'test'@'%';
flush privileges;

4 给test用户授予testdb数据库的insert,delete,update权限(可远程登陆)

grant insert,delete,update on testdb.* to 'test'@'%';
flush privileges;

5 查看用户的权限

show grants for 'test'@'%';