Search code examples
mysqlcodeignitermamp

Unknown MySQL server host 'localhost:81' (0) in CodeIgniter


I am using mamp instead of xamp. In that the localhost configured to port number 81. For mysql it is 3307.

For my case I cannot use the ports 80 and 3306. In database.php of configure in CodeIgniter, how can I specify the host details? If I put localhost:81, it shows the Unknown MySQL server host 'localhost:81' (0). If I give localhost, it takes the localhost:80 to find the db. but I want it to take the db in localhost:81.


Solution

  • Since you know your mysql port is 3307 just add localhost:3307 or 127.0.0.1:3307 in the database.php of your codeigniter setup. localhost:81 is for your application server. Use that in browser to browse your app.