mysql修改密码
2020-11-08 22:30
801 查看
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>
相关文章推荐
- Navicat无法直连MySQL怎么办?
- 性能优化利器:剖析MySQL 5.7新特征 sys schema
- MySQL中,21个写SQL的好习惯(修正版)
- MySQL数据库高危权限回收参考
- ## 【分布式事务】面试官问我:MySQL中的XA事务崩溃了如何恢复??
- MySQL数据库命令行界面不支持中文
- MySQL数据库多实例介绍及安装
- 学习MySQL之主从复制与读写分离一篇就够了!(数据库并发能力的提升)
- 减轻内存负担,在 pymysql 中使用 SSCursor 查询结果集较大的 SQL
- mysql常见技巧汇总
- Mysql5.7实现主从 延迟数据复制
- MySQL死锁系列-线上死锁问题排查思路
- 带你了解 MySQL Binlog 不为人知的秘密
- 通过 ansible 部署二进制 mysql 8
- MySQL性能测试初试(1)--sysbench
- MySQL:SELECT COUNT 小结
- MySQL索引
- MySQL中间件之ProxySQL(2):Admin管理接口
- 面试命中率90%的点 —— MySQL锁
- 单独安装mysql客户端