zoukankan      html  css  js  c++  java
  • MySQL数据库远程连接开启方法

    有时候需要远程连接mysql数据库,默认是不可以的,可以参考下面的方法,解决下。

    1、登陆自己机器的MySQL数据库:mysql -uroot -p密码 

    设置root用户可以任意IP访问,代码如下(可选,这里%代表任意,也可以指定IP):

    MySQL>update user set host = '%' where user = 'root'; 
    MySQL>select host, user from user; 


    2、MySQL>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

    予任何主机访问数据的权限 

    3、MySQL>FLUSH PRIVILEGES;

    修改生效 

    4、MySQL>EXIT 

    退出MySQL服务器 

    这样就可以在其它任何的主机上以root身份登录啦!

    在其他机器上输入IP和端口(端口默认3306),亲测OK

    C:UsersXXXXX>mysql -uroot -proot -h192.168.0.3 -P3307
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 936
    Server version: 5.5.28 MySQL Community Server (GPL)

    Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

    mysql>

  • 相关阅读:
    可运行的Java RMI示例和踩坑总结
    JS异步与同步
    Github作为Maven仓库
    Jmeter笔记
    nodeJS生成xlsx以及设置样式
    double运算的坑
    mysql零散操作
    go包的理解
    nodeJS 服务端文件上传
    webpack+thymeleaf实现数据直出
  • 原文地址:https://www.cnblogs.com/huige-you/p/4280979.html
Copyright © 2011-2022 走看看