CruiseControl.rb throwing exception with Postgres - ruby

In a VPS I have Postgres installed and 2 Rails projects. Both are running on production mode and connecting PG as different users.
Now I want to set CruiseControl.rb for one of them. Everything went perfectly, except when cruise is trying to run the test it's throwing this error:
PGError: ERROR: permission denied to create database
: CREATE DATABASE "myProject" ENCODING = 'utf8'
This test database is created with a different owner name, and all of them are specified correctly in ~/.cruise/projects/myProject/work/config/database.yml.
When I am running these following series of commands manually inside ~/.cruise/projects/myProject/work, they are working perfectly.
RAILS_ENV=test rake db:migrate
rake test
I've created the database using these following commands:
create user test_user with password 'abcxyz';
create database test_database TEMPLATE template0 owner test_user;
grant all privileges on database test_database to test_user;
After hitting the Build Now button, the test_database is getting deleted, and then its trying to create it again and throwing that exception.
I'm puzzled, why the test db is getting deleted on the first place? Is there anything I'm missing here?

It sounds like you haven't granted access to your test user to create a new database, even though you issued permissions for the test_user on the existing test_database.
You may need to grant privileges to create a new DB like so:
GRANT CREATE ON SCHEMA public TO test_user;
The commands you executed before created the test_user and so must have been executed as an admin or the postgres user.
TL;DR
You should compare the permissions for your cruise user to the user you executed these steps with manually, something is wrong preventing the test db creation during db:test:prepare

Related

How to add a superuser privilege to a postgres user

I can't add a superuser privilege to a new db through this command:
alter user postgres with superuser
I get this error:
Failed to run sql query: must be superuser to alter superuser roles or change superuser attribute
I ran the command in Supabase SQL Editor.
I ran the command successfully in a db that I created a month ago with the result:
Success. No rows returned
Let me know where I am going wrong.

Postgres does not create role

I have installed postgres via brew. However, after running rake db:create I get error
role 'posgres' does not exist
I can not run psql as role of my user does not exist, which is logical, but I can not login with -u postgres either.
Any suggestions, how to create postgres user ?
It seems like the service is not running / turned on after instal.
Documentation reference:
https://www.postgresql.org/docs/current/static/server-start.html
Then perform initdb /[data location]
Then you will need to sudo to postgres user (the service user) to issue commands to the database.

DB2 Express in MAC SQL0805N issue

I have db2 express on mac, db2start works, and db2 connect works.
However when I do anything on the database it gives me an error (eg. db2 list tables):
SQL0805N Package "NULLID.SQLC2J23 0X4141414141564962" was not found.
SQLSTATE=51002
I try doing this:
/Users/myuser/sqllib/bnd> db2 bind #db2ubind.lst blocking all grant public
And get these errors:
LINE MESSAGES FOR db2ubind.lst
------ --------------------------------------------------------------------
SQL0061W The binder is in progress.
LINE MESSAGES FOR db2ajgrt.bnd
------ --------------------------------------------------------------------
SQL0551N "TESTDB" does not have the required authorization or
privilege to perform operation "BIND" on object
"NULLID.SQLABJ02". SQLSTATE=42501
LINE MESSAGES FOR db2ueiwi.bnd
------ --------------------------------------------------------------------
SQL0551N "TESTDB" does not have the required authorization or
privilege to perform operation "BIND" on object
"NULLID.SQLUAJ19". SQLSTATE=42501
I also already did this (which seems to not help):
sudo chown root /Users/$(whoami)/sqllib/security/db2ckpw
sudo chmod u+rxs /Users/$(whoami)/sqllib/security/db2ckpw
sudo chmod o+rx /Users/$(whoami)/sqllib/security/db2ckpw
Did I miss something?
#client
> db2level
DB21085I Instance "blahblah" uses "64" bits and DB2 code release "SQL10010"
with level identifier "0201010E".
Informational tokens are "DB2 v10.1.0.0", "s120905", "DARWIN64101", and Fix
Pack "0".
Product is installed at "/Users/username/sqllib".
#server
Instance server = DB2/AIX64 10.5.5
Is it not possible to connect from a 10.1 client to 10.5.x server?
The meesage says that you do not have the BIND right in the database.
So ask your DBA to grant you the bind right and redo the bind command.
The DBA has to issue
grant bindadd on database to user testdb
grant bind on database to user testdb
Alternatively the right could be granted to a group or role or the DBA has to run the bind under his authority.

Windows: how can I set my PostgreSQL user to the superuser?

I am trying to create a database using PostgreSQL 9.4. I type "psql" in the command prompt, and then it asks for a password. I provide the password I set during the installation, but it says the authentication failed. After checking online, I concluded that I need to be using the superuser, named "postgres", which is the system user whose password is the one I set during the installation.
I am now trying to set PostgreSQL to this superuser. I spent a lot of time surfing the internet for a solution but wasn't able to solve the problem. I tried postgres ALTER USER myuser WITH SUPERUSER (I wrote that in the Windows command prompt), but it said that "alter" isn't recognized. Now, when I try to use PostgreSQL, my main problem is that I get the error: "role MYUSERNAME does not exist". (this is after I edited pg_hba.conf to make it not ask for a password)
By default, psql uses the name of the operating system to log in, to a database of the same name. If you want to log in as user postgres you should do:
psql -u postgres <any other options>
If a password is asked for, you give the password of the postgres user. You are now connected to the postgres database, where you really shouldn't be doing anything, except create new users (which are global to the installation) and other databases.
Once in the console, you can create new users like:
CREATE ROLE myusername LOGIN PASSWORD secret;
And new databases like:
CREATE DATABASE myowndb;
ALTER DATABASE myowndb OWNER TO myusername;
Then you log out from the console with \q.
In order to be able to access PostgreSQL using the new database, you have to edit the pg_hba.conf file (sample, modify to match your network settings):
host myowndb myusername 192.168.0.0/16 md5
Now you restart the PostgreSQL server from the Services tab in Administrative tools on the Control Panel.
Then you can log in to your new database:
psql -u myusername -d myowndb
Or use other clients like pgAdminIII.
Under Windows. The Postgres bin directory ships with the user commands createuser.exe and dropuser.exe.
Say, if running initdb (effective fresh install) or for some other reason there is no superuser (like the question).
Can also manage the users and superusers (-s option) with the above two commands. ie.
Create the superuser called postgres:
C:"Program Files"\PostgreSQL\15\bin\createuser.exe -s postgres
Drop a user:
C:"Program Files"\PostgreSQL\15\bin\dropuser.exe postgres

Oracle 11g XE initialization on ubuntu 12.04

I was following this tutorial:
http://sysadminnotebook.blogspot.com/2012/10/installing-oracle-11g-r2-express.html
and I sucessfully installed and started oracle database. Now I wanted to connect to that DB from bash, so I found that command:
sqlplus sys as sysdba
It asks for password, which in my case is oracle, and after I supply it, I get:
ORA-01031: insufficient privileges
What should I do?
EDIT:
I needed to add group dba and add myself to that group. However I've got other problem now. I wanted to create user, so I did:
CREATE USER myuser IDENTIFIED BY password
default tablespace users
temporary tablespace temp;
And I got: ORA-01034: ORACLE not available.
I tried: STARTUP But I got:
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/xe/dbs/initXE.ora'
I have '/u01/app/oracle/product/11.2.0/xe/dbs/init.ora' file but not initXE.ora
Is the o/s user a member of the dba group?
If this is a new installed Oracle and you do not have initXE.ora parameter file here /u01/app/oracle/product/11.2.0/xe/dbs/, that means you need to create XE DB first. To do that run /u01/app/oracle/product/11.2.0/xe/bin/createdb.sh script first.

Resources