- Where Developers Learn, Share, & Build Careers
When I try to run a php code working on my local host instead of a web server, Getting the error.
WARNING: mysqli :: mysqli () [mysqli.mysqli]: [2002] Connection refused Any ideas how the MySQL username , DB, and password to work from my local machine? I'm using OS X Mountain Lion and Apache.
Thank you!
Itemprop = "text">
Unless you have the default password root to connect to the local host If not, then something like this will happen:
connect_errno) {echo "failed to connect to MySQL: (" MySqli-> Connect_errno. ")". $ Mysqli- & gt; Connect_error; } Echo $ mysqli-> Host_info "\ N"; $ Mysqli = new mysqli ("127.0.0.1", "user", "password", "database", 3306); If ($ mysqli-> connect_errno) {echo "failed to connect to MySQL: (" MySqli-> Connect_errno. ")". $ Mysqli- & gt; Connect_error; } Echo $ mysqli-> Host_info "\ N"; ? & Gt; You can take the place of localhost by IP, depending on how your database is configured to allow connections using a local host or a clear IP.
Comments
Post a Comment