• Linux系统操作MySql常用命令


    基础命令:

    mysql -uroot -proot:连接mysql服务,root分别为用户名和密码

    use xxx:切换到 xxx 数据库,xxx为数据库名称

    create database xxx;:创建一个名为 xxx 的数据库

    show databases;:显示所有数据库,注意末尾带s

    drop database xxx;:删除名为 xxx 的数据库

    select database();:查看当前使用的是哪个数据库

    show tables;:显示当前数据库有哪些表信息,注意末尾带s

    select version(),current_date;:显示当前mysql版本和当前日期

    用户授权等命令:

    select user,host from user;:查看用户权限信息

    grant all privileges on *.* to 'root'@'%' with grant option;:
            1、给用户授权,all代表所有权限(CRUD)等,*分别代表库名和表名,%所有访问IP
            2、权限:all(所有权限),usage(无权限),select,update,insert,delete(指定权限),update(字段1,......,字段N) 指定字段
            3、访问权限:%(所有主机),localhost(数据库服务器本机)
            4、语法:grant 权限列表 privileges on 库名.表名 to '用户'@'IP地址' with grant option;

    grant select, update, delete, insert on *.* to 'root'@'%' with grant option;:为root用户授予所有库和表的(CURD)权限

    revoke all privileges from root;:撤销root用户的所有权限

    alter user 'root'@'%' identified with mysql_native_password by 'xxx';:修改root用户(%代表所有访问IP)的密码,xxx为变更的新密码

    update user set password=password(”123456″) where user=’root’;:修改系统管理员 root 用户的密码为123456

    flush privileges;:刷新更新或配置信息,使之生效

  • 相关阅读:
    MFC为“对话框中的控件添加变量”,QT中使用“ui.对象名称”来调用控件
    滑动窗口代码
    方程、等式、函数
    ThreadLocal线程变量使用浅解
    vscode设置参考线
    生成验证码
    Python学习之pandas模块duplicated函数的常见用法
    可验证的idea才是真的
    day29 SQL注入&增删改查&盲注&延时&布尔&报错
    从Spring为什么要用IoC的支点,我撬动了整个Spring的源码脉络
  • 原文地址:https://blog.csdn.net/hkl_Forever/article/details/125462267