今天嘗試從linux下安裝Mysql數(shù)據(jù)庫,需要遠程測試時發(fā)現(xiàn)3306端口無法被遠程機器訪問。一開始以為是linux防火墻對于3306端口做了限制,但是關(guān)閉防火墻后發(fā)現(xiàn)也無法進行telnet。
經(jīng)查詢相關(guān)資料發(fā)現(xiàn),mysql默認對于本地連接做了綁定,如果需要遠程機器訪問,則需要修改相關(guān)規(guī)則
具體如下
1.找到如下文件
/etc/mysql/mysql.conf.d/mysqld.cnf
2.打開該文件,顯示
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
3.找到 bind-address 項
注釋該項或者添加指定訪問遠程機
# bind-address = 127.0.0.1
bind-address=127.0.0.1 xx.xx.xx.xx