The Postgresql role is the owner of the db 'university' and it's been configured like,
alter user canoe password 'mypassword';
The piece of embedded SQL code in C just makes a connection to DB.
printf("SQLSTATE=[%s]\n", SQLSTATE);
EXEC SQL CONNECT TO 'university' USER 'canoe/mypassword'
printf("SQLSTATE=[%s]\n", SQLSTATE);
The code is compiled and linked. It's run on the localhost on which the postgresql server is running and listening on its default port.
$ ecpg connection.pgc
$ gcc -I/usr/include/postgresql connection.c -o conn -lecpg
The output of the compiled code is:
SQLSTATE=[00000]
SQLSTATE=[08001]
The error code 08001 means "sqlclient_unable_to_establish_sqlconnection". I've changed the configuration of postgresql to log all connection attempts in order to debug the code.
LOG: parameter "log_connections" changed to "on"
LOG: 00000: parameter "log_error_verbosity" changed to "verbose"
However, when the compiled code is run, there is no any error. When I connect it with pgsql, it has log info.
$ pqsql university -W
LOG: connection authorized: user=canoe database=university
The wired thing that I notice is even I enter wrong password after prompt, I can still get authorized. But my piece of C code doesn't work.
I can't resolve the issue or have any idea to debug it further. Any idea to where is the issue?
Related
I am running SQL Server Linux container images with Docker on Debian Linux version 11.
I have connected successfully as 'root#sql1' from the command line with username 'SA':
I have downloaded AzureDataStudio, but can't make a connection:
Note that I am using the same password.
I have entered the port '1433' under Advanced Settings, and this leads to the following error:
Thank you.
I'm using the following guide to install MSSQL server on my ubuntu 16.04 machine
https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-2017
when I'm running:
sudo /opt/mssql/bin/mssql-conf setup
no matter what kind of SQL Server edition I choose, I'm getting the following error:
Confirm the SQL Server system administrator password:
Configuring SQL Server...
This program has encountered a fatal error and cannot continue running at Mon Apr 1 16:06:07 2019
The following diagnostic information is available:
Reason: 0x00000007
Message: Cannot open or read the persistent registry: \SystemRoot\security.hiv.
Process: 19600 - sqlservr
Thread: 19604 (application thread 0x4)
Instance Id: 7ebfcf27-db60-460d-afd3-6d852b70069e
Crash Id: d99ba388-d323-43f3-b758-e116f42bb2e8
Build stamp: 70437f6583b8ef39b1ef70539ef84690980315dc7a4436c9c40015f28610e4aa
Distribution: Ubuntu 16.04.6 LTS
Processors: 8
Total Memory: 16673366016 bytes
Timestamp: Mon Apr 1 16:06:07 2019
Ubuntu 16.04.6 LTS
Capturing core dump and information to /var/opt/mssql/log...
Hint: You are currently not seeing messages from other users and the system.
Users in the 'systemd-journal' group can see all messages. Pass -q to
turn off this notice.
No journal files were opened due to insufficient permissions.
Hint: You are currently not seeing messages from other users and the system.
Users in the 'systemd-journal' group can see all messages. Pass -q to
turn off this notice.
No journal files were opened due to insufficient permissions.
/usr/bin/tail: cannot open '/var/log/syslog' for reading: Permission denied
Attempting to capture a dump with paldumper
Captured a dump with paldumper
Core dump and information are being compressed in the background. When
complete, they can be found in the following location:
/var/opt/mssql/log/core.sqlservr.04_01_2019_16_06_07.19600.tbz2
Initial setup of Microsoft SQL Server failed. Please consult the ERRORLOG
in /var/opt/mssql/log for more information.
also I found this post, which look like this guy had a similar problem, but sadly no solution
does any one knows how to solve my problem?
Thank you
Edit:
after implementing the answer I got another error:
Confirm the SQL Server system administrator password:
Configuring SQL Server...
Initial setup of Microsoft SQL Server failed. Please consult the ERRORLOG in /var/opt/mssql/log for more information
To make some clean in the mess that I had in the log folder I decided to delete it completely using
sudo rm -rf /var/opt/mssql/log
and re-run the setup, Apparently that solved my last problem and finally:
Setup has completed successfully. SQL Server is now starting.
You'll find further information in
/var/opt/mssql/log
Mine said:
{
"reason": "0x00000007",
"processName": "sqlservr",
"pid": "5773",
"instanceId": "d7df749c-50e6-4f3b-b894-2aa7c743f33d",
"crashId": "281e772a-5946-4349-aa9e-671cd0a3772c",
"threadId": "5777",
"libosThreadId": "0x4",
"buildStamp": "70437f6583b8ef39b1ef70539ef84690980315dc7a4436c9c40015f28610e4aa",
"message": "Cannot open or read the persistent registry: \\SystemRoot\\lsa.hiv.",
"last_errno": "13",
"last_errno_text": "Permission denied",
"distribution": "Ubuntu 16.04.6 LTS",
"processors": "4",
"total_memory": "16732037120",
"timestamp": "Fri Apr 12 22:02:44 2019"
}
So I ran locate to see where "systemroot" is located:
locate security.hiv
/var/opt/mssql/.system/system/security.hiv
I didn't know which permissions should be applied, so I just gave read&write to "others".
then the same with
lsa.hiv
licensing.hiv
re-run
sudo /opt/mssql/bin/mssql-conf setup
and then, sql-server starts, plus the permissions for others are gone again.
By the way, you can run sql-server without service, then it works even if the service fails:
/opt/mssql/bin/sqlservr
In my case (#Mine) it was not only licensing.hiv.
My /var/opt/mssql/.system/instance_id was somehow destroyed and there were more files with owner root.
After deleting /var/opt/mssql/.system/instance_id and changing all root.root files to mssql.mssql (chown mssql.mssql /var/opt/mssql/.system/system/*), I was able to rerun "/opt/mssql/bin/mssql-conf setup"
Afterwards mssql runs fine again
I very goog hint was that "/var/opt/mssql/.system/instance_id" runs on his own.
Something! has happened and I cannot login anymore using SSMS to my local SQL Server Express and this is the error I get:
So I Googled it and found this website solution which I ran:
https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context-to-master/
But then this is the error I get:
I also tried and put my computer name instead of LocalHost in that command, but again same error.
Whenever i launch my app, part of my task is to first run a migration. however, I get the below error 95% of the time.
Command failed: /bin/sh -c node_modules/.bin/sequelize db:migrate
Unable to connect to database: SequelizeConnectionRefusedError: connect ECONNREFUSED
Details:
killed: false
code: 1
signal: null
cmd: /bin/sh -c node_modules/.bin/sequelize db:migrate
stdout:
Sequelize [Node: 0.12.7, CLI: 2.1.0, ORM: 3.14.0]
Note: I can still query and connect to the database after the failure, also when i check the TCP lsof -i tcp:5432 its only one instance of postgres that runs.
I would appreciate any assistance in solving this issue.
I had similar issue , but in my case it turn out I didn't start my posgres. Make sure your posgress is started and open otherwise Sequelize would fail. I just solve mine. Also mind your username and password . my connection is simple below.
var db ='postgres://user:#localhost:5432/my_db_naame'
var sequelize = new Sequelize(db);
where user is your database user . my_db_naame is your db name. See the doc here . I suggest you install posgres client terminal. Like the one here http://postgresapp.com/documentation/gui-tools.html . Make sure you open it and the elephant sign is shown on top . Or better connect , try your username and password. run some queries and then try your sequelize again.
I want to monitor NTP error message to catch synchronization fail like network unreachable, server error etc..
When I add logconfig =allall in /etc/ntp.conf, and restart ntpd, trying to get more information when error occurs, but the output information is not enough for me to monitor.
But, if I run ntp in debug mode, like "ntpd -u ntp:ntp -p /var/run/ntpd.pid -g -D 4", I can get more detail information.
Could I just modify ntp config file to do the same thing as debug mode?
By the way, logconfig seems not written on man page.
Thank you!
You don't say which OS you are running this on, or trying to configure this for but... if its a linux OS then have a look in the following file.
/etc/sysconfig/ntpd that is the default options file which is read when the daemon is started. My default config contains OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
You should be able to modify that to suite your requirement of additional logging.