mysql 学习笔记(一)

时间:2022-11-07 18:33:11

查询:
show databases;

show status;

show tables;

desc  table-name;

更改root密码:
方法一:mysqladmin -uroot -poldpassword  password newpassword
方法二:
mysql -uroot -p
use mysql
update user set password=password("newpasswd") where user="root";

select host,user,password from user;

+-----------+------------------+-------------------------------------------+
| host      | user             | password                                  |
+-----------+------------------+-------------------------------------------+
| localhost | root             | *FAE22ED156CC483651E55164E12EE8597A798849 |
| c600      | root             | *FAE22ED156CC483651E55164E12EE8597A798849 |
| 127.0.0.1 | root             | *FAE22ED156CC483651E55164E12EE8597A798849 |
| ::1       | root             | *FAE22ED156CC483651E55164E12EE8597A798849 |
| localhost | debian-sys-maint | *BF673A86346B2E5CFFEFA24D36E2C520F0B82A49 |
| localhost | test             | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 |
+-----------+------------------+-------------------------------------------+

创建/授权用户:
grant select ,delete,update,insert,drop on db_name.* to user_name identified by "passwd" ;

grant all on db_name to user_name ;