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;

  • 相关阅读:
    leetcode ---Search a 2D Matrix
    leetcode ---Search for a Range
    LeetCode--Search in Rotated Sorted Array
    LeetCode--setatrixzeroes
    LeetCode--sortColor
    LeetCode--Spiral Matrix
    java io类 和servlet类 的UML图表示
    servlet web.xml配置详解
    解决json日期格式带T问题
    在拦截器中获取请求参数,[Ljava.lang.String; cannot be cast to java.lang.String报错
  • 原文地址:https://www.cnblogs.com/liruning/p/6020144.html
Copyright © 2011-2022 走看看