zoukankan      html  css  js  c++  java
  • Linux下mysql创建用户并设置权限,设置远程连接

    为了安全考虑,OneinStack仅允许云主机本机(localhost)连接数据库,如果需要远程连接数据库,需要如下操作:
    打开iptables 3306端口

    # iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
    # service iptables save //保存iptables规则

    # iptables -nvL //查看端口开启情况

    =======================================================================================
    root用户登录mysql   mysql5.7版本使用
    mysql>create database SubAccount;
    mysql>GRANT ALL PRIVILEGES ON SubAccount.* TO drcloudapi@"%" IDENTIFIED BY "123456" WITH GRANT OPTION;  // *.*表示所有库的所有表
    mysql>flush privileges;
    mysql>use SubAccount;

    =================================================================================

    mysql5.7版本password已经改为authentication_string

    insert into mysql.user(Host,User,authentication_string) values("%","zizhanghu",password("123456")); //<=5.1版本能用
    //GRANT ALL PRIVILEGES ON SubAccount.* TO zizhanghu@"%" IDENTIFIED BY "123456" WITH GRANT OPTION;
    //为用户创建一个数据库(SubAccount):
    mysql>create database SubAccount;
    //授权yanzm用户拥有SubAccount数据库的所有权限(某个数据库的所有权限):
    mysql>grant all privileges on SubAccount.* to zizhanghu@'%' identified by '123456';
    //刷新系统权限表
    mysql>flush privileges;
    mysql>use SubAccount;

  • 相关阅读:
    php中的多态
    面向对象的继承与组合
    PHP中的__call和__callStatic方法
    PHP中的__set和__get方法
    PHP中对象的本质
    mysql字符串查找(统计客源)
    linux查看文件大小
    mysql常用字符串操作函数大全,以及实例
    mysql滑动订单问题
    mysql列反转Pivoting
  • 原文地址:https://www.cnblogs.com/liruning/p/6020144.html
Copyright © 2011-2022 走看看