localbyflywheelを使用してwordpressでpdo接続をしたいのですが、SQLSTATE[HY000] [2002]とエラーがでて接続できません。
私の確認する箇所が間違ってなければ、パス等は間違っていないと思っています。
wordoressでpdo接続する際は根本的にやり方が違うのでしょうか?
php
1$dsn = 'mysql:host=localhost; dbname=local; charset=utf8'; 2$username = "root"; 3$password = "root"; 4try { 5 $dbh = new PDO($dsn, $username, $password); 6} catch (PDOException $e) { 7 echo $e->getMessage(); 8}
wp-config.php
php
1// ** MySQL settings - You can get this info from your web host ** // 2/** The name of the database for WordPress */ 3define( 'DB_NAME', 'local' ); 4 5/** MySQL database username */ 6define( 'DB_USER', 'root' ); 7 8/** MySQL database password */ 9define( 'DB_PASSWORD', 'root' ); 10 11/** MySQL hostname */ 12define( 'DB_HOST', 'localhost' ); 13 14/** Database Charset to use in creating database tables. */ 15define( 'DB_CHARSET', 'utf8' ); 16 17/** The Database Collate type. Don't change this if in doubt. */ 18define( 'DB_COLLATE', '' ); 19
回答1件
あなたの回答
tips
プレビュー