mysql修改密码

mysql修改密码
mysqladmin -u  root -p password  修改初始密码
mysql  
忘记root密码的处理方法
修改配置文件
vim /etc/my.cnf

添加文件 skip-grant-tables
跳过密码验证
直接 mysql -u root -p  登录进去修改密码

update mysql.user set authentication_string=password(‘sha1234567‘) where user=‘tom‘;
修改root密码
update mysql.user set authentication_string=password(‘abc123‘) where user=‘root‘;
flush privileges; 刷新

 grant all on *.* to ‘jerry‘@‘localhost‘ identified by ‘abc123‘;

 grant all on *.* to ‘root‘@‘%‘ identified by ‘abc123‘;

-------------------------------------------------------------------------------------

创建普通用户,及设置权限
 -------------------------------------------------------------------

创建用户jerrry ,并提权(如果没有jerry 用户,会自动创建)
 grant all on *.* to ‘jerry‘@‘localhost‘ identified by ‘abc123‘;

查看查看用户权限的命令是?
SHOW GRANTS FOR 用户名@来源地址
 查看jerry 的权限
mysql> show grants for ‘jerry’@‘localhost’;

--------------------------------------------------------------------

 撤销用户权限的命令
REVOKE 权限列表 ON 数据库名.表名 FROM 用户名@来源地址

撤销JERRY用户的权限

mysql> revoke all on *.* from ‘jerry‘@‘localhost‘;
Query OK, 0 rows affected (0.00 sec)

----------------------------------------------------------------------------

Grand :当用户已存在时,直接提权,当用户不存在时,先创建用户再提权

Revoke : 只撤销权限,不会删除用户
-------------------------------------------------------------------------------------------------------

在mysql 库下 操作此命令,查看用户登录权限

% 表示在所有终端网段
mysql> select user,host from user;
+-----------+-----------+
| user      | host      |
+-----------+-----------+
| root      | %         |
| mysql.sys | localhost |
| root      | localhost |
+-----------+-----------+
3 rows in set (0.00 sec)

删除ROOT本地登录权限

mysql> drop user root@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from user;
+-----------+-----------+
| user      | host      |
+-----------+-----------+
| root      | %         |
| mysql.sys | localhost |
+-----------+-----------+
2 rows in set (0.00 sec)

---------------------------------------------

windows
测试登录
mysql  带密码登录

C:\Users\sha>mysql -uroot -h 192.168.100.12  -pabc123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.17 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>
---------------------------------------------------------------------

mysql 交互模式登录
C:\Users\sha>mysql -uroot -h 192.168.100.12  -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.17 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

mysql修改密码

上一篇:【UR #17】滑稽树前做游戏


下一篇:数据库与高可用第三章索引,事务,存储引擎