Creating User For Postgresql - django

When I enter su postgres it is asking for a password and I did not set any prior password.
I am using a Django book and have installed PostgreSQL with sudo apt-get install PostgreSQL PostgreSQL-contrib I installed it within a virtual environment the instructions are vague on where to install so I just install it in there. Also installed the install the psycopg2 PostgreSQL adapter for Python with
pip install psycopg2-binary==2.8.4. I am now in the next step to create a user for the PostgreSQL but can't pass that step the instructions provided are to enter su postgres and immediately after createuser -dp user-name and it is asking for a password. I have entered my superuser password but showing authentication failure.
Thanks

in your linux terminal write the commands
sudo -s
su postgres
psql
then you connect to postgres
to create a user from psql you type
create user username with encrypted password 'password';
to create a database with specific owner you type
create database databasename with encoding 'utf8' owner username;
to exit from psql you type
\q
last but not least to alter the password for user postgres with psql run the command
alter user postgres with encrypted password 'password';
then restart the postgresql server
sudo service postgresql restart

Related

superset server not running

I am following the below instructions to install superset. In this step "superset runserver -d" getting an error below. How do I fix this issue. Thanks
[DEPRECATED] As of Flask >=1.0.0, this command is no longer supported, please use flask run instead, as documented in our CONTRIBUTING.md
[example]
flask run -p 8080 --with-threads --reload --debugger
# Install superset
pip install superset
# Create an admin user (you will be prompted to set a username, first and last name before setting a password)
fabmanager create-admin --app superset
# Initialize the database
superset db upgrade
# Load some data to play with
superset load_examples
# Create default roles and permissions
superset init
# To start a development web server on port 8088, use -p to bind to another port
superset runserver -d
Yesterday commit https://github.com/apache/incubator-superset/pull/5966 fixed similiar issue with docker install. Try to clone repo from scratch and go trough the following steps:
git clone https://github.com/apache/incubator-superset/
cd incubator-superset/contrib/docker
# prefix with SUPERSET_LOAD_EXAMPLES=yes to load examples:
docker-compose run --rm superset ./docker-init.sh
# you can run this command everytime you need to start superset now:
docker-compose up
New installation doc: https://github.com/apache/incubator-superset/blob/master/docs/installation.rst
Try the below steps:
$ pip install flask==1.0.0
$ pip install sqlalchemy==1.2.18
$ pip uninstall pandas
$ pip install pandas==0.23.4

Access denied After MySQL Manual Installation on Google Compute Engine

Somehow I wanted to install MySQL manually, so I did as explained in How to Set Up MySQL on Google Compute Engine except that I didn't need to create a VM instance because I already have one.
That is, since my OS is 'Debian GNU/Linux 9 (stretch)', I executed the following two commands to install MySQL:
$ sudo apt-get update
and
$ sudo apt-get -y install mysql-server
There's no errors in this step and I created a root password by the following command:
$ sudo mysql_secure_installation
But when I tried to connect to MySQL, (entering the root password I created)
$ mysql --user=root --password
I've got
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
What would be a problem here and what should I check in order to connect to MySQL?
There is an error on the tutorial. In order to connect to the MySQL you should run:
$ sudo mysql --user=root --password

Password for ec2-user on AWS Cloud9

I am trying to run $ sudo su in the terminal of AWS Cloud9. I get prompted for the password for the ec2-user. Any ideas what this might be?
Might be worth noting that prior to coming up against this issue, when trying to yum install a package, I got 'packages excluded due to repository priority protections' so I ran yum erase yum-plugin-priorities as per https://serverfault.com/questions/312472/what-does-that-mean-packages-excluded-due-to-repository-priority-protections (I'm fairly sure I had to do that with sudo but wasn't prompted for the password).
First you need to set your password using command
$ sudo passwd ec2-user
Then you can use the new password where ever its required
I ran into the same problem which trying to install homebrew on my ec2#Cloud9 Env.
When requested for password, I didn't place any let the program wait for a while after which I could see the package homebrew got installed.
In the cloud9 (terminal) you have to change the users password with:
$ sudo passwd ec2-user
Changing password for user ec2-user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Use "sudo passwd root" or "sudo passwd"

Getting Started With Django video series - issue with Postgres database creation

I am on a virtualenv running on vagrant following http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/, and when I type:
$ sudo su postgres
I get asked to enter a password:
$ [sudo] password for postgres:
Does anyone have any tips for how to find the password? I'm confused that I'm even getting this password request, since previously, this is what happened:
createuser: creation of new role failed: ERROR: role "vagrant" already exists
postgres#precise64:/vagrant/projects/microblog$ createuser -P
could not change directory to "/vagrant/projects/microblog"
(blog-venv)vagrant#precise64:/vagrant/projects/microblog$ createdb microblog
createdb: database creation failed: ERROR: permission denied to create database
(blog-venv)vagrant#precise64:/vagrant/projects/microblog$ sudo su postgres
postgres#precise64:/vagrant/projects/microblog$ dropuser vagrant
could not change directory to "/vagrant/projects/microblog"
postgres#precise64:/vagrant/projects/microblog$sudo -u postgres psql postgres is not in the sudoers file. This incident will be reported.
postgres#precise64:/vagrant/projects/microblog/microblog$ sudo su postgres
[sudo] password for postgres:
Ultimately I'm trying to make the createdb microblog create a database for me in Postgres, but I'm running into these strange password request issues.

Heroku django app createsuperuser

I deployed my django app and when I tried
heroku run python manage.py syncdb
I got a timeout awaiting process error. Superuser is not created for the system yet, though i did syncdb by using:
heroku run:detached python manage.py createsuperuser
But this does not prompt me for the superuser.
Port 5000 is not blocked in my system. How do I make heroku run work (or) how do I create the super user?
do not detach the heroku shell:
heroku run python manage.py createsuperuser
worked for me
after wasting entire day i got the answer
heroku run python manage.py syncdb
doesn't run on institute or office lan to run this you must remove system proxy as well
unset http_proxy
`unset https_proxy`
I hope this will help
Try
heroku run python manage.py shell
And then create your superuser from there. Good luck!
More info please.
What DB are you using?
Have you set your local_settings.py?
Are you using Debian?
I use Postgres on Debian so I had to both apt-get install python-psycopg2 (otherwise you can't use postgres) and pip install --user psycopg2 (otherwise pip freeze misses Postgres), then manually create a user and db. Replace USER with the username from your local_settings.py
sudo su - postgres
createuser USER -dPRs
createdb --owner USER db.db