• MySQL基础


    为数据库创建特定的用户和密码

    mysql>grant all privileges on <database>.* to '<username>'@'localhost' identified by '<password>';
    mysql>grant all privileges on <database>.* to '<username>'@'localhost' identified by '<password>';
    

    举例,为icebug用户创建专属的数据库icebug_db,且密码为icebug_passwd

    mysql>create database icebug_db;
    mysql>grant all privileges on icebug_db.* to 'icebug'@'localhost' identified by 'icebug_passwd';     # 目的是本地可访问
    mysql>grant all privileges on icebug_db.* to 'icebug'@'%' identified by 'icebug_passwd';             # 目的是远程主机可以访问
    

    创建好了之后就可以直接通过用户icebug和密码icebug_passwd登陆数据库系统了,注意通过icebug账号和icebug_passwd登陆之后只能看到数据自己的数据库,并不能看到别人的数据库,这也是为什么要为特定数据库创建特定账号和密码了,千万注意不要人手一个root账号和密码.....

    登陆

    icebug@localhost:~$ mysql -uicebug -picebug_passwd
    

    这样就可以登陆icebug的数据库了~

    tips:

    最好不要这样直接把密码放到命令行里一块敲,不然很容易在bash history中留下密码痕迹,出于安全考虑还是通过mysql -uicebug -p之后再敲入密码为好。

  • 相关阅读:
    ArrayList源码解析
    HashSet的实现原理
    Spark Streaming之四:Spark Streaming 与 Kafka 集成分析
    Spark Streaming之三:DStream解析
    Spark Streaming之二:StreamingContext解析
    curl与wget区别
    MongoDB之二(增删查改)
    Thread之九:stop
    mysql实战优化之九:MySQL查询缓存总结
    PBE加密算法
  • 原文地址:https://www.cnblogs.com/dspace/p/6111621.html
Copyright © 2020-2023  润新知