postgresql gives permission issues - database

Postgresql is not cooperating. I did a yum of postgresql and postgresql-server and that seemed to be fine. I then tried to `` and it gives and error message:
createdb: could not connect to database postgres: FATAL: Ident
authentication failed for user "postgres"
If I remove the user it gives the same error just with my username. I'm on a Centos OS. I want it to work with apache and php after I figure out to create a database.
When I run /usr/bin/postgres it gives an error:
/usr/bin/postgres does not know where to find the server configuration
file. You must specify the --config-file or -D invocation option or
set the PGDATA environment variable.
Can't figure it out. Did I miss a configuration step? I thought doing yum would work out of the box.

Sounds like it is configured for ident authentication which requires you to login as the linux user postgres ie:
su postgres
and then run the createdb command. Other method would be to locate your pg_hba.conf probably in something like /var/lib/pgsql/9.1/data and switch to trust authentication. That way you can connect using -U postgres with any linux account and it will let you in without verifying the password. Then you can setup required usernames and passwords and then switch to something more secure like md5.

Related

Import/Export PostgreSQL db "without" pg_dump or sql file / backup, etc...?

I need to import a old db into a new postgre server.
Is there a way to migrate an old database to a new server without using pg_dump?
I don't have the sql file, or the old server backup file, neither the user and the password, just the physical files in the "\data" folder, is there any way to do this?
The target server is in the same version of th old server.
Thanks.
Well as a test you could try:
pg_ctl start -D $DATA
Where pg_ctl comes from the target version and the $DATA is the the /data directory. You have not said how you came to have just a /data directory. If this came from an unclean shutdown or a corrupted drive the possibility exists that the server will not start.
UPDATE
To get around auth failure find pg_hba.conf and create or modify local connection to use trust method. For more info see pg_hba and trust. Then you should be able to connect like:
psql -d some_db -U postgres
Once in you can use ALTER ROLE to change password:
ALTER ROLE <role_name> WITH PASSWORD 'new_password';

Can't select database - Wordpress

When I download a new wordpress from wordpress.org and then paste it into my www folder of WAMP, then create a new database in phpmyadmin, then go to localhost and click the wordpress site, it asks to create the config file, and enter the database details, and i do that correctly, but when I click submit, it says "Can’t select database".
Any Idea why this is?
I already have a local wordpress site that started saying error connecting to database. The config settings are all correct so i tried to download a fresh wordpress site and use it and I cannot even set up a fresh one. I have never encountered a fresh wordpress site not working like this before.
I did a msqldump of my old site so that my boss could put it on his server. Not sure if that is relevant.
Cheers.
Please don't overcomplicate.
In the "Database Host" field add "localhost: e.g. in my case "localhost:3308" solved the problem.
For anyone who's still looking for solutions to this problem - please, check again your wp-config.php database credentials again. I had the same problem today and tried to over-complicate the matter by searching for advanced solutions, while I had a space in my DB_NAME field (was supposed to be 'wpdb' and was ' wpdb').
This space completely messed up my connection, I was even close to reinstalling the whole thing and losing all data.
If using LAMP -
Make sure that all privileges are granted for that database to the created mysql user. Under your MYSQL shell use the below
GRANT ALL PRIVILEGES ON database_name.* TO database_user#localhost IDENTIFIED BY 'user_password';
Where,
database_name = your database name as per wp-config.php
database_user = your user name as per wp-config.php
userpassword = your user password as per wp-config.php
It sounds like either you have not created a database or your wp-config file is not set up correctly. Have you edited wp-config.php file of wordpress and provided correct database name and user credentials. See Famous 5 minute installation of wordpress for details.
It took me way too long to discover that my msql databases were not working on any other websites either. I reinstalled Wamp Server and it worked.
Verify the wp-config.php file.
I had the same error and the problem was related with the quotes:
‘root’ vs 'root'
edit: the correct one is single quote
'
By default
username : root
password : leave it blank
database host : localhost
table_prefix : wp_
For me, the solution was giving wp_user all permissions on the wp_db database.
I achieved this using the command line interpreter (CLI):
$ mysql -uroot -p
MariaDB [(none)]> GRANT ALL ON `wp_db`.* TO `wp_user`#`localhost` IDENTIFIED BY 'pass';
MariaDB [(none)]> exit;
After these operations, I restarted the database:
$ systemctl restart mysql
Of course, the database name (wp_db), username (wp_user), and password of the user (pass) can be different.
my problem was that when I granted permissions to the DB user the host did not match what was in the wp_config.php
/** MySQL hostname */
define('DB_HOST', 'localhost:3306');
I was granting rights with
GRANT ALL ON databaseName.* TO 'UserName'#'127.0.0.1';
This gave me access when I was connected to the local host through ssh but It did not match wp_config.php. so I had to Grant like this then it all worked.
GRANT ALL ON databaseName.* TO 'UserName'#'localhost';
For Mariadb hostname should be localhost:3306 and for MySQL localhost:3308.this fixed my error.
I had this issue when trying to transfer databases between WAMP server installations.
I tried opening PhpMyAdmin on new PC, then got the port of MySql server (:3308) and added this port into DB_HOST ('localhost:3308'). This worked for me.
please create your database with name 'wordpress' before installing wordpress
You may need to create the database yourself.
Visit http://localhost:8888/phpMyAdmin5
create a new database with the name you prefer.
Don't add any table names, just use the name you choose for the database in the WordPress setup

how to tell if oracle database is installed on pc

i work for a company as java developer, they gave me laptop that was previously used by another person, to test my java application i need to have oracle on laptop and create some sample database with sample data. when I got the laptop i found that there is oracle installed on it, but i don't know if this is only oracle client or full oracle installation (server + client)
please can you tell me how to figure out if there is only oracle client on laptop or full database installation, plus i need to know if there is some default username and password so that i can access the database and create schema and tables in it, so that i can test my java application.
i thinking to see DBA but i thought of dropping a question here first, maybe i can solve the problem by myself
If it is an Oracle Client, it doesn't have bin/dbca
Oracle Home may indicate the installation's type. The default Oracle Home folder names are:
Oracle Database: dbhome_1
Oracle Client: client_1
Although to make sure, you should check the services looking for OracleServiceSID entry on Windows.
Run Command sqlplus on command prompt.
Check services of windows to know that the oracle database was installed on laptop or not.
Try to find oracle universal installer in all programs by this also you can get which version of database is installed.
Your second question is about default username/password
For this you can give username : "/ as sysdba".
It will not ask for password because it will authenticate thorugh OS authentication.
after login you can able to create new schema or user and tables.
You can check simply using command prompt. Open command prompt and type connect. Provide the username and password and press Enter. It will show "connected" if the database is in your system.
Username: system (default)
Password: (what you provided while installing)
Firstly goto my computer/ this pc and then click on
downloads option and see your app and check that Oracle
is available there or not.

ADD ODBC database via batch file with Username/password

I need to install an ODBC database on a few computers and was hopeing to do it all via a batch file. I can get it to install the database connection string like so.
ODBCCONF.exe CONFIGSYSDSN "SQL Server" "DSN=DSNNAME | Description=Descriptionname| SERVER=ServerName | Trusted_Connection=Yes | Database=dbname"
pause
#CLS
#Exit
But i need to add that it should log in with with an Login ID and password NOT with the network login ID.
Anyone know how i can fix this?
also its on 64 bit windows 7
Thanks
http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/53f689c1-53c8-45c6-b9ce-c44bce46cd9d/ says "Persistence of login credentials in a DSN is not supported (it's insecure). Using trusted connection would be the best way to achieve connecting without specifying credentials since the logged on user credentials is used for authenticating to the server."
If you change to Trusted_Connection=No it will add the DSN, but you'll then need to run the ODBC Data Source Admin and add the user and pwd to the new DSN by hand.
btw, according to http://msdn.microsoft.com/en-us/library/windows/desktop/ee388579%28v=vs.85%29.aspx "ODBCCONF.exe will be removed in a future version of Windows Data Access Components. Avoid using this feature, and plan to modify applications that currently use this feature."

oracle 10g xe install on ubuntu. problems logging in and creating database

objective: to install oracle 10g xe on ubuntu.
method followed :www.oracle.com/technology/tech/linux/install/xe-on-kubuntu.html
problem: The installation went fine and at 1 point it asked me for a password for the system account and I gave it lets say 'securepassword' that. Now, I have 2 problems:
I want to create a database. There is a createdb script in the bin directory, but everytime I run it, it says :
ORACLE_HOME must be set and $ORACLE_HOME/dbs must be writable
So I set the ORACLE_HOME but i still get the problem. I figure that since all files in the dbs directory are owned by the 'oracle' user and the dba group, I'll su to oracle and run the command. Turns out 'securepassword' doesnt work for the oracle user. The Oracle installation created a user called 'oracle' but gave it some passwod I dont know about. Whats this password ?
I also tried adding my current user to the dba group and trying it again. Didnt work either
When I run ./sqlplus from the bin directory, I try to login as sys\'securepassword'. Didnt work! Tried system\'securepassword'. Didnt work either.
The only place system/'securepassword' worked was to get into the apex web interface.
Can someone tel me the default password for the oracle user and how to login to sqlplus ?
I can think of three reasons why
sqlplus sys\'securepassword'
wont' work:
You're using backslashes. Use forward slashes instead.
Don't put quotes around the password.
If connecting as SYS, you'll need to add as sysdba as otherwise you get the following error message:
ERROR:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
So, assuming that securepassword is the password for both SYS and SYSTEM, both of the following lines should work:
sqlplus sys/securepassword as sysdba
sqlplus system/securepassword
In Oracle, 'OS-based authentication' means that if your Ubuntu user account is a member of the dba group, then you can log in as SYS without a password by typing
sqlplus / as sysdba
in a shell window. This is handy if you forget your SYS password and need to reset it.
Incidentally, I ran into a completely non-obvious issue installing Oracle 10g XE on my openSUSE box. I needed to run
chown oracle /var/tmp/.oracle
as root to clear up a permissions error which prevented the database from starting.
In the linux terminal, type:
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/sqlplus.sh
It should bring you into the SQLPlus commandline.
To connect, type:
connect sys as dba
Then fill in your password when prompted. Done!
Can you log in as sys with os based authentication? Then you should be able to set passwords, etc.
sqlplus / as sysdba
?
After re-reading the question, it sounds like you are trying to find the password for the OS user "oracle"? If you installed the software as root, you should be able to set a new password for the user "oracle" using the passwd utility.

Resources