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;

  • 相关阅读:
    js数组
    ECharts测试
    java代码测试---插入排序和选择排序
    C++语言基础——01一切的开始
    咸鱼君的算法学习笔记——快速排序
    6-4英语句子
    《浪潮之巅》二十二、二十三章笔记
    《浪潮之巅》第二十一章笔记
    《浪潮之巅》二十章笔记
    《浪潮之巅》十八十九章笔记
  • 原文地址:https://www.cnblogs.com/liruning/p/6020144.html
Copyright © 2011-2022 走看看