pg: unknown authentication message response: 10 (Golang) [duplicate] - postgresql

I'm trying to follow the diesel.rs tutorial using PostgreSQL. When I get to the Diesel setup step, I get an "authentication method 10 not supported" error. How do I resolve it?

You have to upgrade the PostgreSQL client software (in this case, the libpq used by the Rust driver) to a later version that supports the scram-sha-256 authentication method introduced in PostgreSQL v10.
Downgrading password_encryption in PostgreSQL to md5, changing all the passwords and using the md5 authentication method is a possible, but bad alternative. It is more effort, and you get worse security and old, buggy software.

This isn't a Rust-specific question; the issue applies to any application connecting to a Postgres DB that doesn't support the scram-sha-256 authentication method. In my case it was a problem with the Perl application connecting to Postgres.
These steps are based on a post.
You need to have installed the latest Postgres client.
The client bin directory (SRC) is "C:\Program Files\PostgreSQL\13\bin" in this example. The target (TRG) directory is where my application binary is installed: "C:\Strawberry\c\bin". My application failed during an attempt to connect the Postgres DB with error "... authentication method 10 not supported ...".
set SRC=C:\Program Files\PostgreSQL\13\bin
set TRG=C:\Strawberry\c\bin
dir "%SRC%\libpq.dll" # to see the source DLL
dir "%TRG%\libpq__.dll" # to see the target DLL. Will be replaced from SRC
cp "%SRC%\libpq.dll" %TRG%\.
cd %TRG%
pexports libpq.dll > libpq.def
dlltool --dllname libpq.dll --def libpq.def --output-lib ..\lib\libpq.a
move "%TRG%"\libpq__.dll "%TRG%"\libpq__.dll_BUP # rename ORIGINAL name to BUP
move "%TRG%"\libpq.dll "%TRG%"\libpq__.dll # rename new DLL to ORIGINAL
At this point I was able successfully connect to Postgres from my Perl script.
The initial post shown above also suggested to copy other DLLs from source to the target:
libiconv-2.dll
libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
libintl-8.dll
However, I was able to resolve my issue without copying these libraries.

Downgrading to PostgreSQL 12 helped

Related

Bareos Postgres Plugin NOT backing up remote PostgreSQL13 database

I've installed Bareos 20.0.1 on Ubuntu 20.04.3 according to their documentations here.
I'm trying to backup a remote PostgreSQL database and apparently, there are three possible scenarios and the pros of the PostgreSQL Plugin (third solution), makes it the obvious choice.
Following the PostgreSQL Plugin documentations, in the Prerequisites for the PostgreSQL Plugin section, there is a line saying:
The plugin must be installed on the same host where the PostgreSQL database runs.
Now what I'm failing to understand is that, if I'm supposed to install the plugin on my database node, how will the bareos machine and the plugin on the db machine communicate?
Furthermore, I've checked out the source code for this module on their GitHub, and I see that the plugin source code tries to find files locally and that is a proof to the aforementioned statement.
In a desperate act, I tried installing the plugin and its dependencies on the bareos node and I keep getting the error Error: python3-fd-mod: Could not read Label File /var/lib/postgresql/13/main/backup_label which is actually trying to find the backup_label file in the bareos node.
Here is the configuration for my fileset:
FileSet {
Name = "psql"
Include {
Options {
compression=GZIP
signature = MD5
}
Plugin = "python"
":module_path=/usr/lib/bareos/plugins"
":module_name=bareos-fd-postgres"
":postgresDataDir=/var/lib/postgresql/13/main"
":walArchive=/var/lib/postgresql/13/wal_archive/"
":dbHost=DATABASE_DNS"
":dbuser=DATABASE_USER"
}
}
Note that the plugin document specifies the dbHost parameter as:
useful, if socket is not in default location. Specify socket-directory with a leading / here
However, since I'm trying a remote database, I'm using the DNS address of the remote database. I verified the bareos connection to database and made sure the backup_label file gets created while the PostgreSQL backup job runs.
I'll be happy to provide more details if necessary. Appreciate any help or even guesses :-D

Failed to load sql modules into the database cluster during PostgreSQL Installation

I have attempted to install PostgreSQL 9.4 and 8.4 multiple times and it is failing no matter what I have tried. I am attempting to install on Windows 7 SP1 x64. After each failed install I have uninstalled and deleted the installation folder to start fresh.
Each time I attempt the install I get an error pop up near the end of installation that says:
"failed to load sql modules into the database cluster".
Then another error pop up displays immediately after that says:
"Error running post install step. Installation may not complete correctly. Error reading C:/Program Files/PostgreSQL/9.4/postgresql.conf"
I have attempted installation with the following actions:
Always installed as administrator
Turned off all virus protection and windows firewall
Changed the installation directory to something other than the Program Files directory.
Changed the data directory to something other than the installation directory of postgres
None of the actions above have helped and I always receive the error. Any help that someone can provide would be greatly appreciated!
Encountered a very similar problem that OP is reporting today while installing Postgres 9.4.
It turns out that the password generator I was using has made a password that contains non-alphanumeric characters. ("^") I believe was the culprit in this case. Removing that allowed the installation of Postgres 9.4 (Windows 64 bit) to complete.
Very easy fix once you've found it, but the error message that comes up is not descriptive, so in this case I didn't notice at first what I was doing wrong.
I was getting this same error when trying to install PostgreSQL v9.4.4 on Windows 10 Pro. Starting with a solution hosted on Stack Exchange, I came up with the following steps that allowed the installer to run successfully:
1) Create a new user account, called postgres
2) Add the new account to the Administrators and Power Users groups
3) Restart the computer
NOTE: I added step #3, since step #4 didn't work without it
4) Run a command prompt as the postgres user, using the command:
runas /user:postgres cmd.exe
5) Run the installer from the postgres command window
6) Delete the postgres user account, as well as the user directory
NOTE: I added step #6, since the postgres account is not required after installation
What worked for me is, during the install, specifying a Postgre SQL data folder that's outside of any Windows user profile directory (C:\Users), such as C:\postgres-data.
My setup:
Win 10 Pro
PostgreSQL 9.5 RC1
I ran into this issue when I tried setting PostgreSQL's data directory somewhere under my user profile's directory, such us somewhere under "My Documents".
I tried Jeff G's solution and it didn't work at first. It worked only when I kept the data directory as the default (C:\Program Files\PostgreSQL\9.5\data). So then I tested further and tried setting the data directory to somewhere outside of any user profile directories (i.e. somewhere that isn't under C:\Users). For example, C:\postgres-data and this worked.
I then just tried using that directory with my default user, and not bothering with the postgres temp user as outlined in Jeff G's solution and that also worked. So in the end, it had to do with my data directory being somewhere under C:\Users. As long as it was outside of that, it worked.
None of these answers here helped me, finally I solved this problem by creating the folder before the installation (C:\PostgreSQL\data) and giving it full access for the group "Users".
Windows 7 x64, postgresql-9.5.2-1-windows-x64
Hope It's Work.
1.)Uninstall PostgreSQL
2.)Delete the postgres user if it still exists :
net user postgres /delete
3.) Create the postgres user with a password you can remember:
net user /add postgres
4.) Add the postgres user to the Administrators group:
net localgroup administrators postgres /add
5.) Add the postgres user to the Power Users group
net localgroup "power users" postgres /add
6.) Run a command window as the postgres user:
runas /user:postgres cmd.exe
7.) Change user postgres and install postgresql
8.)Back your and remove the postgres user from the Administrators group.
net localgroup administrators postgres /delete
I had the same error ("Failed to load SQL modules into the database cluster.") when installing on W2K12R2 using the EnterpriseDB installer linked to from the PostgreSQL Windows download page. I tried running the installer with admin privs, and using the postgres-user solution offered by Jeff G, but neither worked. Finally I tried the second installer, BigSQL, and that installed without issue.
When installing PostgreSQL, do not use the following symbols in your database's admin password: %, <, and >.
Bug report and problem solution here
Changed the data directory to something other than the installation directory of postgres
Make sure NETWORK SERVICE has read/write permissions on that folder, the installation was failing for me until I did this.
I had this issue too with 9.5 and got around it by:
Installing with the default data folder.
Making sure my new data folder had full control access for the "NETWORK SERVICE" account.
Then changing the default PGDATA folder as per this instruction: https://wiki.postgresql.org/wiki/Change_the_default_PGDATA_directory_on_Windows
I had the same problem, and noticed that some Postgres .bat files were opening in a text editor. Text editors opening files during installation isn't too uncommon, but I noticed these batch files were setting directory permissions. I then found that .bat files were set to open in a text editor (Notepad++) by default. I changed the default program for .bat files, uninstalled Postgres, re-ran the installer, and it worked perfectly. Hope this helps.
I had the same problem before. I solved this by installing Visual Studio C++ Express first.
I had the same experience as #gomisha. #Jeff G's solution did not work for me no matter which user ran the installer.
As long as the target data directory was anywhere under c:\users, the install or database cluster init would fail.
I was successful after creating c:\postgresql-data and ensuring that the postgres user had full access in the 'effective access' tool.
Note: I did not use control userpasswords2 to set up the postgres user; I did it through the traditional crappy Windows 10 user wizard that tries to make the user sign up for hotmail. I did run the install as postgres.
I was getting this issue with the BigSQL windows installer PostgreSQL-9.6.5-1-win64-bigsql.exe
The problem turned out to be that my system path was too long. After removing some uncessary junk from my System Path, and then reinstalling, the problem was gone.
One of the answers here is the only thing that worked on my machine:
I had the same error message when trying to install 9.2.4. My issue
was because even though the Win2k8 server had %SYSTEMROOT%\system32 as
part of the path, no programs could "see" anything in
C:\Windows\system32. The installer heavily uses icacls.exe during the
init routine. Since my path was screwed up, the installer bombed out.
Once I explicitly added C:\Windows\system32 to the SYSTEM's Path
environment variable and re-ran the installer as an admin, everything
worked fine.
Credits to the user.
Go to services.msc
Search for postgres service
Go to Log On tab
Select local account
Profit
The alternative solution for problems with PostgreSQL installer is setting this up with a Docker.
Install Docker Desktop
https://www.docker.com/products/docker-desktop/
Start installed Docker Desktop
In PowerShell, run:
docker pull postgres
In PowerShell, run:
docker run -d -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=mypassword postgres
Now you can connect to the Postgres server for example with pgAdmin on the same machine, using:
host: localhost
port: 5432
maintenance database: postgres
username: postgres
password: mypassword
I think this would be better as individual comments above, but I don't have the required rep. I just spent days on this, with Postgres 10 on Win 10 Creators. My "answer" was to let Postgres put the data in its default install folder instead of my User folder (where it would be automatically backed-up).
1. This problem can happen with no reported install errors at all. On my very first try, I saw:
Failed to load SQL modules into the database cluster.
But that seemed to be due to:
Executing C:\Users\loren\AppData\Local\Temp\postgresql_installer_aee8e5a76f\vcredist_x64.exe /passive /norestart
Script exit code: 3010
MSI (s) (AC:FC) [14:21:35:341]: Product: Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.40660.
Restart required. The installation or update for the product required a restart for all changes to take effect.
The restart was deferred to a later time.
Restarting Windows after the failure of the rest of the Postgres installation did not let Postgres run.
Once VC was in place, uninstalling and re-installing Postgres (still with its data in my User folder) completed with no reported errors. But every attempt to access it, by any means, still resulted in something like this:
C:\Program Files\PostgreSQL\10\bin>psql
psql: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
The RawCap sniffer showed TCP SYN followed immediately by RST,ACK on localhost for both v4 and v6 for each try. Netstat did not see port 5432 in use at all. All Postgres runtime logs were totally empty. In Windows Services, I could manually start the postgresql-x64-10 service, but it immediately stopped itself, with the note that some services do that normally.
2. I tried moving the data directory via the Postgres wiki procedure. Apparently for Postgres 10 it is incomplete. It does not deal with:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-10\Data Directory
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Services\postgresql-x64-10\Data Directory
C:\Program Files\PostgreSQL\10\pg_env.bat
C:\Program Files\PostgreSQL\10\scripts\serverctl.vbs
But fixing every data file instance I could find did not let it run. And even after fixing all those, and uninstalling and re-installing again with the default location, the new pgAdmin4 somehow still remembered my original User data directory location!
3. I did not try giving NETWORK SERVICE read/write permissions on my User folder. Once the default install worked I wanted to get on with my original project... Maybe that would have worked.

Another RMySQL Windows 7 install issue

I am trying to install RMySQL on my Windows 7 Professional x64 machine using R-2.15.1, RTools 2.16 (also tried 2.15), and MySQL 5.5.
I have copied libmysql.dll and libmysql.lib into mysql\lib\opt and \bin. I have also copied libmysql.dll into R-2.15.1\bin.
I have set Renviron.site properly as confirmed by Sys.getenv('MYSQL_HOME') using both the 8.3 nomenclature as well as non-8.3 nomenclature.
Sample output for Sys.getenv('MYSQL_HOME') is "C:/Program Files/MySQL/MySQL Server 5.5/" (quotes included). When I use 8.3 nomenclature it also is correct.
Here is the relevant part of my PATH:
c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;C:\Program Files\MySQL\MySQL Server 5.5\lib\opt;c:\program file\R\R-2.15.1\bin;
I have manually inserted it into the registry in the right location (because the MySQL 5.5 doesn't do that properly - it only puts it under the Wow6432Node) AND I inserted it into the system variables to deal with this error:
Error in utils::readRegistry("SOFTWARE\MySQL AB", hive = "HLM", maxdepth = 2) :Registry key 'SOFTWARE\MySQL AB' not found
I even tried
Sys.setenv('MYSQL_HOME=C:/Program Files/MySQL/MySQL Server 5.5/')
However, when I try to install RMySQL I get the following error:
checking for $MYSQL_HOME... not found... searching registry...
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.1/bin/x64/Rscript
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-215~1.1/bin/x64/Rscript
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Try setting MYSQL_HOME to one of the following (you may have to use the non-8dot3 file name):
ERROR: configuration failed for package 'RMySQL'
If I am understanding the error properly, it can't find MYSQL_HOME, even though it calls it properly using Sys.getenv, is located in the proper location in the registry, AND is a system variable.
I have a similar issue with my Windows 7 x64 installation.
I think the problem is not related to the MYSQL_HOME, but to the registry.
As you can see here:
https://dev.mysql.com/doc/refman/5.1/en/windows-install-wizard.html
the default location for the registration is not SOFTWARE\MySQL AB but SOFTWARE\Wow6432Node\MYSQL AB.
I believe the answer is here:
http://martin.von-gagern.net/howtos/20110728-rmysql/

PostgreSQL issue: could not access file "$libdir/plpgsql": No such file or directory

I get this exception in PostgreSQL:
org.postgresql.util.PSQLException: ERROR: could not access file "$libdir/plpgsql": No such file or directory
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1721)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1489)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:193)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:337)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:236)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)
I searched a lot and most solution points to a wrong installation. But this is my test db which has been running without issues for a long time. Also inserts are working. Issue occurs only on select queries.
Apparently, you moved your PostgreSQL lib directory out of place. To confirm this, try the following in psql:
> SET client_encoding TO iso88591;
ERROR: could not access file "$libdir/utf8_and_iso8859_1": No such file or directory
If you get an error message like this, then my theory is correct. You'll need to find out where those files ended up, or you can reinstall PostgreSQL to restore them.
To find out what $libdir is referring to, run the following command:
pg_config --pkglibdir
For me, this produces:
/usr/lib/postgresql
I have the same problem: the other postgres server instance (8.4) was interfering with the 9.1 one; when the 8.4 instance is removed it works.
the other instance can sometimes be removed from the system while still running (e.g. you do a gentoo update and a depclean without stopping and migrating your data). so the error seems particularly mysterious.
the solution is usually going to be doing a slot install/eselect of the old version (in gentoo terms, or simply downgrading on other distros), running its pg_dumpall, and then uninstalling/reinstalling the new version and importing the data.
this worked pretty painlessly for me

How recover sybase database (unknown db version)

I have a database file (*.db) that need to be recovered.
The bad is, the end-user have null idea of the version of the database. Not know the password. The original developer is lost. The computer where was installed was formatted. We have not experience in this database software. Yeah, nightmare.
My guess is a old database. I'm trying to open it in Sybase 11, dev edition.
I follow this steps: http://dcx.sybase.com/1101en/sachanges_en11/unloading-reloading-upgrading-newjasper.html
I try to use the UNLOAD utility from command line & from the Sybase central utility. From command line I do:
./dbinfo -c "DBF=/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB;UID=DBA;PWD=sql"
SQL Anywhere Information Utility Version 11.0.1.2045
Unable to start specified database: '/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB' was created by a different version of the software
Ok, I try to unload:
./dbunload -c "DBF=/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB;UID=DBA;PWD=sql" -n /Users/mamcx/Desktop/
SQL Anywhere Unload Utility Version 11.0.1.2045
Connecting and initializing
***** SQL error: Unable to start database server
Ok, from the server admin tool:
dbunload -v -c "UID=dba;PWD=***;DBF=/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB" -an "/Users/mamcx/Desktop/baba.db" -ap 4096 -ea None -ii -sa -so _sc866192545
Connecting and initializing
***** SQL error: Unable to start database server
An error occurred while attempting to unload the database '/Users/mamcx/Downloads/CEMDE_ENDOCRINO_S.A.DB'.
Exist a way to know the version of the database server used to create this? Is possible to recover this file?
I don't know how to get the version out of the Database File if you are not able to start it.
You could get a hint from the hopefully existing Client PC's. Check the ODBC Driver Version they have installed.
I had good success with the support of Sybase. If you or your client has a support contract you can get them involved.
HTH
Try to simply start a server with that database and capture the output with -z -o server.out. The server.out file should contain a more specific error telling you why it can't start the database. This error can occur if you are trying to start something that is not a SQL Anywhere database.
You may also want to post this question over at http://sqlanywhere-forum.sap.com/.