MySQL資料庫遠端連線開啟方法

來源:互聯網
上載者:User

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:\Users\XXXXX>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>

本文永久更新連結地址:

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.