zoukankan      html  css  js  c++  java
  • Linux系统下实现远程连接MySQL数据库的方法教程

    1、在服务器端开启远程访问
    首先进入mysql数据库,然后输入下面两个命令:

    grant all privileges on *.* to 'root'@'%' identified by 'password';
    flush privileges;
    第一个*是数据库,可以改成允许访问的数据库名称
    第二个 是数据库的表名称,代表允许访问任意的表
    root代表远程登录使用的用户名,可以自定义
    %代表允许任意ip登录,如果你想指定特定的IP,可以把%替换掉就可以了
    password代表远程登录时使用的密码,可以自定义
    flush privileges;这是让权限立即生效
    2、修改my.cnf配置文件
    这个是mysql的配置文件,如果你无标题文章找不到在哪里的话,可以输入find /* -name my.cnf 找到

    通过vim编辑该文件,找到bind-address    = 127.0.0.1这一句,然后在前面加个#号注释掉,保存退出

    3、重启服务

    service mysql restart
    4、在本地远程连接
    在终端输入:

    mysql -h 服务器ip地址 -P 3306 -u root -p
    然后输入密码即可。
    root是第1点设置的用户名,密码也是第1点设置的密码

    Install 3 Packages (+2 Dependent packages)
    Total download size: 171 M
    Downloading packages:
    mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 00:03:42
    mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm | 2.0 MB 00:00:03
    mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:00:05
    mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 00:00:41
    warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA
    Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed
    mysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:00:01
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Importing GPG key 0x5072E1F5:
    Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
    Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
    Package : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch)
    From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Installing : mysql-community-common-5.7.10-1.el7.x86_64 1/6
    Installing : mysql-community-libs-5.7.10-1.el7.x86_64 2/6
    Installing : mysql-community-client-5.7.10-1.el7.x86_64 3/6
    Installing : mysql-community-server-5.7.10-1.el7.x86_64 4/6
    Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64 5/6
    Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6
    Verifying : mysql-community-server-5.7.10-1.el7.x86_64 1/6
    Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64 2/6
    Verifying : mysql-community-common-5.7.10-1.el7.x86_64 3/6
    Verifying : mysql-community-libs-5.7.10-1.el7.x86_64 4/6
    Verifying : mysql-community-client-5.7.10-1.el7.x86_64 5/6
    Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6
    Installed:
    mysql-community-libs.x86_64 0:5.7.10-1.el7 mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 mysql-community-server.x86_64 0:5.7.10-1.el7
    Dependency Installed:
    mysql-community-client.x86_64 0:5.7.10-1.el7 mysql-community-common.x86_64 0:5.7.10-1.el7
    Replaced:
    mariadb-libs.x86_64 1:5.5.44-2.el7.centos
    Complete!
    [root@typecodes ~]# clear

  • 相关阅读:
    python出现local variable 'f' referenced before assiginment""
    使用Python修改ifcfg-eth0文件
    在linux中运行py文件时,及时知道错误信息
    分词结果准确率、召回率计算-python
    oozie工作流
    combiner hadoop
    Python常用模块--base64
    Python常用模块--datetime
    树莓派(Raspbian系统)中使用pyinstaller封装Python代码为可执行程序
    LeetCode刷题笔记--Python--28. 实现strStr()
  • 原文地址:https://www.cnblogs.com/2881064178dinfeng/p/7010328.html
Copyright © 2011-2022 走看看