0
上でPHPを使用して:MySQLへの接続は、私は次のコードを使用してPHPを使用してMySQLデータベースに接続しようとしているUbuntuの14
<?php
$servername = "localhost";
$username = "root";
$password = "pass";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
ローカルホストを使用している場合、私は
Connection failed: No such file or directory
メッセージが表示されますホストに対して127.0.0.1を使用しています。
Connection failed: Connection refused
私はコマンドラインを使用して接続できることを確認しました。出力は低
mysql -u root -p pass -h localhost
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7282
Server version: 5.5.47-0ubuntu0.14.04.1-log (Ubuntu)
次の設定からの/ etc/PHP5/apache2の
mysqli.default_port = 3306
mysqli.default_socket = /var/run/mysqld/mysqld.sock
mysqli.default_host = 127.0.0.1
でphp.iniファイルの関連mysqliのセクションで、TCP
mysql -u root -p pass -h 127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7318
Server version: 5.5.47-0ubuntu0.14.04.1-log (Ubuntu)
を使用した接続/ etc/mysql/my.cnf
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
.
.
.
bind-address = 127.0.0.1
PDOを使用して同じ結果を得てデータベースに接続しようとしました。誰かが正しくない構成設定を見たり、何が間違っている可能性があるか他の考えを持つことができますか?
編集:phpmyadminをインストールし、同じ設定でMySQLに接続します。
以前と同じエラーが表示されます。 – user3074091