test.php文件php
$con=mysqli_connect("127.0.0.1","root","password","test"); // 檢測鏈接 if (mysqli_connect_errno($con)) { echo "數據庫鏈接失敗: " . mysqli_connect_error(); } echo mysqli_get_server_info($con); mysqli_close($con);
執行test.php文件報錯:mysql
數據庫鏈接失敗: Can't connect to MySQL server on '127.0.0.1' (13)
不過將 127.0.0.1改成localhost數據庫就能夠鏈接成功。
liunx 執行/usr/sbin/setenforce 0 ,馬上關閉SELINUX
好使了。。。媽賣批SELINUX的鍋
永久關閉
vi /etc/selinux/config
SELINUX=enforcing改成SELINUX=disabledlinux