zoukankan      html  css  js  c++  java
  • Mariadb设置允许远程链接

    一. 修改数据表

    1.进入 mariadb

    mysql -u root -p

    2.修改表

    MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
    Query OK, 0 rows affected (0.00 sec)
    
    • 第一个位置,为数据库, 第二个位置,为表,所以 *.*,表示可以访问任意数据的任意表
    • 'root'@'%', root表示远端登录使用的用户名,%表示允许任意ip登录,可将指定ip替换掉%, root%可以自定义
    • IDENTIFIED BY 'root' 这个root 是登录时的使用的密码,(方便记忆就用了root,生产环境一定要替换掉)

    3.查看修改后

    MariaDB [mysql]> SELECT host,user,password from user;
    +-----------+------+-------------------------------------------+
    | host      | user | password                                  |
    +-----------+------+-------------------------------------------+
    | localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
    | %         | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
    +-----------+------+-------------------------------------------+
    2 rows in set (0.00 sec)
    
    • | % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |表示修改成功

    二. 修改配置文件

    /etc/mysql/mariadb.conf.d/50-server.cnfbind-address = 127.0.0.1# 注释掉

    三.重启服务

     systemctl restart mariadb.service
    

    四.远程链接

    mysql -u root -proot -h 192.168.199.240 -D mysql

    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 8
    Server version: 10.1.34-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MariaDB [mysql]> 
    

    搞定收工




  • 相关阅读:
    bootmgr is conmpressed联想Z485
    数据库中用开窗函数和复制表结构
    左连接新认识
    sql中的日期查询
    一个数据表通过另一个表更新数据(在UPDAT语句中使用FROM子句)
    StarUML安装与Win7不兼容解决
    SQL中VARCHAR与NVARCHAR存储区别
    Cannot start service SPUserCodeV4 on computer
    SQL中空值与NULL区别
    验证码破解分析
  • 原文地址:https://www.cnblogs.com/surplus/p/15256526.html
Copyright © 2011-2022 走看看