Having trouble connecting your MAMP mysql database wth django?
Add the path DATABASE_HOST and connect it towards
{path to your MAMP directory}/tmp/mysql/mysql.sock
So my connection is for instance
DATABASE_HOST = ‘/Applications/MAMP/tmp/mysql/mysql.sock’
And the full mysql settings for for django
DATABASE_ENGINE = ‘mysql’ # ‘postgresql_psycopg2′, ‘postgresql’, ‘mysql’, ’sqlite3′ or ‘oracle’.
DATABASE_NAME = ‘mydb’ # Or path to database file if using sqlite3.
DATABASE_USER = ‘root’ # Not used with sqlite3.
DATABASE_PASSWORD = ‘root’ # Not used with sqlite3.
DATABASE_HOST = ‘localhost’ # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ‘8888′ # Set to empty string for default. Not used with sqlite3.
DATABASE_HOST = ‘/Applications/MAMP/tmp/mysql/mysql.sock’
DATABASE_NAME = ‘mydb’ # Or path to database file if using sqlite3.
DATABASE_USER = ‘root’ # Not used with sqlite3.
DATABASE_PASSWORD = ‘root’ # Not used with sqlite3.
DATABASE_HOST = ‘localhost’ # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ‘8888′ # Set to empty string for default. Not used with sqlite3.
DATABASE_HOST = ‘/Applications/MAMP/tmp/mysql/mysql.sock’
Its straightforward, but good to know, since adding the mysql.sock file in a folder named tmp seems a bit odd.
Thanks for the article. I am new at python and this got me straight.
it was very helpful, thanks!
Thanks for the article. It got me what I needed to find. I am learning django and was stuck on this for a bit.