Using localdb with a computer on a domain but without a connection gives: SQL Server connection error - windows-server

We expect our software to be able to run on computers connected to a domain. We also expect to be able to connect to a localdb we created under the user account. But when we take the laptop to another network where it can't contact the domain controller we get the following error:
Could not obtain information about Windows NT group/user
'OURDOMAIN\AUser', error code 0x54b.
Is there something I can do to make it work? It seems reasonable to me to expect a domain user's privileges to be remembered when a server is out of sight. Interestingly, if it's not connected to any network it does work ok - it only fails when it is connected to another network.
(I don't want something drastic like "log off and use a local account not on the domain", but something normal and workable for a domain user and installation!)

This error was coming from the simple fact the database owner was the domain user. It would seem that the SQL underlying code likes to check authenticity now and again and so that caused occasional failures in random bits of SQL.
Fixed it by changing the owner to an SQL user:
CREATE LOGIN [ourLocalDbOwner] WITH PASSWORD='';
ALTER AUTHORIZATION ON DATABASE::ourDatabase TO [ourLocalDbOwner];

Related

Hosted MySql, Views, client Ipaddress change and Access Denied

I have a hosted MySql server with many databases each with many views. I access the server remotely from my office using HeidiSql.
Once in a while the IP address of my office changes. When this happens, I have to add the new office IP address to the server using cPanel and the "Remote MySql" tool so that I can remotely connect again.
However, all of the views have definer: USER#OLD_IP_ADDRESS. If I need to change a view, I get Access Denied. Up to now, I have been deleting the view (yes, i can delete the view) and recreating it, which makes the view's definer USER#NEW_IP_ADDRESS, and then I can edit the view -- until the Ip address changes again.
So, my question is: What is the best practice is an environment like this. Is there a way to define the views once and, without causing a security risk, be able to edit the views after an IP Address change.
Thanks for any guidance.
You could loosen the host in the MySQL user account a bit, according to the IP range of your internet provider. That way, you don't need to change it every time you get a slightly different IP:
user#123.456.789.%
user#123.456.%
This of course loosens the security in this account, but if your password is be a good one, it should not be too risky.
A better way is to make the MySQL server only accessible via SSH. In that case, your MySQL server can be set up using the --skip-networking option, as you always connecting from localhost. Your user account can be user#localhost or user#127.0.0.1, which then would solve your above mentioned problem for all times.
HeidiSQL also supports SSH tunneled MySQL connections, see here for some tutorial.

Mysql remote connections

I've an application on windows forms that needs to connect to a remote server with a static ip, however I already installed mysql on the server, provided the next command
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES;
and also put an exception in Windows Firewall, but I'm still unable to connect, I don't know if there is something else to do!, I forgot to say it is a Windows Server 2012 R2
This is not the issue with previliges of user. This is about connection rights. LIke mostly on CPanel we have an option of Remote MySQL. Under this option we either have to provide ip address which we want to allow to connect to mysql or wild card mask % to allow any ip to connect to the server. Check with your hosting how it allows you to connnect. yes these previliges are necessary thay you have given. that is ok but check Remote MySQl if you have cPanel.
Thanks
Check your logs and trap your errors.
Confirm your app can reach the sql port and connect. (From the windows machine, can you telnet to the sql port on the sql server?) If not, look at your firewall, and verify your sql instance is bound to a public ip as Bernd suggests.
Once you know the host can reach the sql server, verify your app is actually connecting. Trap errors from connect functions and read them out.
Then verify the credentials are accepted. Again, trap any errors and read them out in your program.
Then, when you're processing a sql statement, trap any errors and read them out to yourself in your program.
(You may find it useful to write a log file from your program containing any errors you detect on any line of code interacting with your database)
Once you've narrowed down where your issue actually is, a solution will probably present itself. Or at least you'll have narrowed it down, and can update us with a specific error message from where the failure has occured.
Good luck!

mysql user from other host failing unsure why

i've setup a new mysql user on a server that allows access from other servers. i can access it from my dev machine using the credentials i setup.
But on one of my other servers nothing happens when trying to log into mysql using the same credentials that worked on my dev box. any ideas what it might be?
all it does is hang.
Nothing gets added to log files on either the new DB server or the one i'm trying to access from.
i also tested this connection from another server, just to test if my dev box was a fluke andi could access. So all i can think is there's something "wrong" with the server i cant access from.
Please post your query that executes to create this user and privileges.
If you can’t remember the queries you can execute this in your target server to get details about user
SHOW GRANTS for 'root'#'localhost';
You may check these things also .
Firewall setup for the server from the trouble machine.
Can this machine connect to another sql server provided with similar access?
Execute select * from mysql.user ; and check you don’t have duplicates with
different access privileges or passwords .
turns out i had everything setup correctly, as i said i was able to use the same user across other servers just not this one.
turns out my server provider had a network firewall restricting mysql connections. removed and hey presto.
thanks #csf

What is the root error behind "Failed to establish a database connection. Check connection string, username and password."

Looking through google and stackoverflow, I found a number of questions asking about "Failed to establish a database connection. Check connection string, username and password." However, I cannot find anyone that has found what the underlying error is.
I am trying to write my first google script with a database connection; I have a mysql and oracle jdbc getConnection, both of which spawn this error. I have checked, double- and triple-check the connection information to no avail. I know the databases are accessible (can get in through other clients from several different machines like php on a linux box, sql developer on various windows PCs at home and work). How do I determine what the real error is? The error as presented to me is way too generic and abstract.
Environment:
Using a script in a Google Spreadsheet (thus inheriting whatever environment is established by google). I am attempting to use the Google API jdbc and have no further knowledge of the environment variables.
Using the following syntax:
var url = "jdbc:mysql://mysql.cb-pta.com:3306/u4lottery";
var conn = Jdbc.getConnection(url, user, password);
Again, user and password have been verified.
There is a known bug which causes problems with jdbc connections using hostnames. Try using an Ip address instead.
Bizarre, but true.. I lost almost 2 days with this bug....
Here is the link to the bug report....
Just for sake of others finding this older thread. I also had trouble using Apps Script to connect to a Google CloudSQL instance, and had to change from:
Jdbc.getCloudSqlConnection('jdbc:google:rdbms://<IP>/<DB_NAME>', '<USER>', 'PASSWORD');
to standard JDBC MySQL (which worked):
Jdbc.getConnection('jdbc:mysql:// ...same as above...
Also, beware and DO NOT include a '/' behind the DB_NAME - this will also cause failure with user/passwd error message!
One more thing to check is that you have proper firewall settings - to allow access from the source IP you are coming from (in the event of Apps Script, this is likely Google's servers - not you client browser's IP). You may have to open it up to all (0.0.0.0/0)
It might have something to do with your database being behind a firewall. According to Google documentation (in this case, Google Data Studio, but generally applicable): "If your database is behind a firewall, you will need to open access to the all of the following IP addresses. These are used by Data Studio to connect to and query your MySql database."
IP addresses here among other places: https://support.google.com/datastudio/answer/7088031

User facing an issue with MS- Access

Currently user using connections to both TEST and PROD instances using MS Access, and everything goes well. By using ABC user. Now user having problems with APPS user in TEST .
Also, user having the same problem with user XYZ in PROD instance. This user has the ‘SELECT ANY TABLE’ privilege, so it should be able to see the tables, but doesn’t work from MS Access.
Please suggest us.
If you're able to connect via a SQL connection (I'm assuming ODBC) then you'll be using a predefined set of credentials (i.e. you'll be passing a username and password to Access; probably through the connection string).
Chances are that if your user is unable to get into the database directly, their network (AD?) account is not configured with the same elevated privileges that the ODBC connection has.