mysql 開啟遠程服務,mysql開啟

來源:互聯網
上載者:User

mysql 開啟遠程服務,mysql開啟

進入mysqlserver

如下:

Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 810
Server version: 5.6.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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>

敲入如下命令:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

FLUSH   PRIVILEGES;







怎開啟mysql遠程登入帳號

1、確定伺服器上的防火牆沒有阻止 3306 連接埠。
MySQL 預設的連接埠是 3306 ,需要確定防火牆沒有阻止 3306 連接埠,否則遠程是無法通過
3306 連接埠串連到 MySQL 的。
如果您在安裝 MySQL 時指定了其他連接埠,請在防火牆中開啟您指定的 MySQL 使用的連接埠號碼。
2、增加允許遠端連線 MySQL 使用者並授權。
1)首先以 root 帳戶登陸 MySQL
在 Windows 主機中點擊開始菜單,運行,輸入“cmd”,進入控制台,MySQL 的 bin 目錄
下,然後輸入下面的命令。
在 Linux 主機中在命令提示行下輸入下面的命令。
> MySQL -uroot -p123456
123456 為 root 使用者的密碼。
2)建立遠程登陸使用者並授權
> grant all PRIVILEGES on discuz.* to ted@'123.123.123.123' identified by '123456';
上面的語句表示將 discuz 資料庫的所有許可權授權給 ted 這個使用者,允許 ted 使用者在
123.123.123.123 這個 IP 進行遠程登陸,並設定 ted 使用者的密碼為 123456 。
下面逐一分析所有的參數:
all PRIVILEGES 表示賦予所有的許可權給指定使用者,這裡也可以替換為賦予某一具體的許可權,
例如:select,insert,update,delete,create,drop 等,具體許可權間用“,”半形逗號分隔。
discuz.* 表示上面的許可權是針對於哪個表的,discuz 指的是資料庫,後面的 * 表示對於所
有的表,由此可以推理出:對於全部資料庫的全部表授權為“*.*”,對於某一資料庫的全部
表授權為“資料庫名.*”,對於某一資料庫的某一表授權為“資料庫名.表名”。
ted 表示你要給哪個使用者授權,這個使用者可以是存在的使用者,也可以是不存在的使用者。
123.123.123.123 表示允許遠端連線的 IP 地址,如果想不限制連結的 IP 則設定為“%”即可。
123456 為使用者的密碼。
執行了上面的語句後,再執行下面的語句,方可立即生效。
 
怎查看mysql遠端存取是否開啟

查看mysql遠端存取是否開啟?

--------------------------
這個不知道你定義的是指哪方面?

如果是單檢查網路方面的,可以檢查參數:
mysql> show variables like '%skip_networking%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| skip_networking | OFF |
+-----------------+-------+
1 row in set (0.00 sec)

mysql>

若為on則表示沒開通網路連接,只能本機訪問.

如果你是指許可權方面的話,則可以檢查mysql.user來查看:
select * from mysql.user;

其中結果中的列host則表示允許訪問的用戶端機器(其中%表示所有機器,若只針對某機器,則可以指定ip就可以了)
 

相關文章

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.