On Fri, Jan 22, 2016 at 7:06 AM, Galil <il...@ajenta.net> wrote: > That was helpful James, we are nearly there. > > You were right the output was "DB Password:", with an empty string. I > added my password as default value like: > > 'PASSWORD': os.environ.get('CDR_DB_PASSWORD', 'my_password_here'), > > but there is something really strange happening. > > When I use the default localhost IP as HOST I get the following error: > > (1045, u"Access denied for user 'cdraccess'@'localhost' (using password: > YES)") > > > When I use my actual host IP, either as default value within settings.py > or as parameter running the command in the terminal, I get again the > previous error: > > Access denied for user 'cdraccess'@'host_ip_here' (using password: NO)") >> >> Frankly, that will probably fail anyway by design. Unless you've tweaked the MySQL, most out of the box installations will only listen on 127.0.0.1/localhost, and not on any of the interfaces on the host. If you are getting the 'using password: NO' error, that means you either didn't provide a '-p' to the mysql command, or PASSWORD in the settings.py file is coming up empty, regardless of whether or not MySQL is listening on the address you've specified.
> Why is that happening? Please not that the password is printed and it is > correct. > > First things first: Get rid of the .get() calls entirely. Whatever method you are using to pass in the environment variables appears not to be working (or may be partially working and causing unexpected behavior): 'cdraccess': { 'ENGINE': 'django.db.backends.mysql', 'NAME': os.environ['CDR_DB_NAME'], 'USER': os.environ['CDR_DB_USER'], 'HOST': os.environ['CDR_DB_HOST'], 'CONN_MAX_AGE': 0, 'PASSWORD': os.environ['CDR_DB_PASSWORD'], }, You don't want to use .get() here because you don't want a default for things like your DB password, you want it to fail loudly if these values are not provided. Otherwise it's no different than if you entered the values directly in the file (which you were doing anyway as the default arguments for .get()). We want a hard failure here if something is broken with the environment variables. This also ensures that these variables at the very least exist in our environment. If that fails, you should see which key is missing, and can fix it accordingly. For testing this issue specifically, we need to start eliminating causes. I would recommend not using the environment variables until we determine the connectivity issue with MySQL: 'cdraccess': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'portal2', 'USER': 'cdraccess', 'HOST': '127.0.0.1', 'CONN_MAX_AGE': 0, 'PASSWORD': 'yourdbpass', }, Test using these settings. You should also throw in print() statements at the bottom of the file to print the other environment variables like we did with CDR_DB_PASSWORD, just to see what is actually being passed to your settings file. That is likely a separate issue, but may be contributing to our problems here. The above configuration with values manually specified should enlighten us as to whether or not the environment variables are giving us angst. -James -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXPPiyTuJoVs8N1QkJP9oYhuCnfO%3DP2EwXaoFr6eHVSnQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.