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 -pabc123mysql: [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 14Server version: 5.7.17 Source distributionCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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 -pEnter password: ******Welcome to the MySQL monitor. Commands end with ; or \\g.Your MySQL connection id is 15Server version: 5.7.17 Source distributionCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement.mysql>