2016-08-15 150 views
0

我已經擡頭就如何解決這一問題並沒有什麼工作,到目前爲止, 我得到這個錯誤 無連接可以作出,因爲目標機器積極地拒絕它 我使用Linux的每一個教程centos7 mysql版本 mysql版本14.14 Distrib 5.6.32,用於Linux(x86_64)使用EditLine封裝 blow is my.cnf 我還必須創建自己的my.cnf,因爲當我安裝mysql時它沒有一個位於我把它放到etc/my.cnf中,它運行的是cnf,因爲它將mysql從嚴格模式中取出。的MySQL連接被拒絕

# For advice on how to change settings please see 
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html 
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the 
# *** default location during install, and will be replaced if you 
# *** upgrade to a newer version of MySQL. 

[mysqld] 

# Remove leading # and set to the amount of RAM for the most important data 
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 
# innodb_buffer_pool_size = 128M 

# Remove leading # to turn on a very important data integrity option: logging 
# changes to the binary log between backups. 
# log_bin 

# These are commonly set, remove the # and set as required. 
# basedir = ..... 
# datadir = ..... 
# port = ..... 
# server_id = ..... 
# socket = ..... 

bind-address = 0.0.0.0 
#skip-networking 

# Remove leading # to set options mainly useful for reporting servers. 
# The server defaults are faster for transactions and fast SELECTs. 
# Adjust sizes as needed, experiment to find the optimal values. 
# join_buffer_size = 128M 
# sort_buffer_size = 2M 
# read_rnd_buffer_size = 2M 

sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 
+0

你能否提供一點細節。您是否試圖通過MySQL客戶端(或其他軟件)或遠程訪問本地計算機? – cherrysoft

+0

〜我試圖通過我的網站使用php連接到mysql,但說警告:mysqli :: mysqli():(HY000/2002):由於目標機器主動拒絕,無法建立連接。在第8行的C:\ xampp \ htdocs \ test.php中 連接失敗:由於目標機器主動拒絕連接,因此無法建立連接。 –

回答

0

好吧,我假設你已經安裝了這個完全不同的機器上(而不是在虛擬主機上的Windows中)。

您需要確保首先在您的數據庫服務器上打開端口3306。你可以用端口檢查器來檢查(有很多免費的在線)。

然後,用戶嘗試連接的用戶需要確保該用戶可以訪問源IP地址(即Windows機器上的IP)。這可以通過mysql提示符下面的代碼完成。

GRANT ALL PRIVILEGES ON <your db name>.* TO <your user>@<your ip> IDENTIFIED BY '<your password>'; 

不太安全的選項是通過使用%通配符來允許所有入站IP。

之後,您需要運行以下命令。

FLUSH PRIVILEGES; 

應該是這樣。

+0

好吧,它的工作感謝兄弟你是一個生活的節省感謝一切保持活躍,你真棒 –

+0

不客氣! – cherrysoft