8

I'm trying to setup a local firebird instance to test against but am unable to connect to it with even ISQL. I have tried to following by following the quick start guide here:

CONNECT ..\examples\empbuild\employee.fdb user SYSDBA password masterkey;

Which resulted in:

Statement failed, SQLSTATE = 08001
unavailable database

After some searching I tried modifying that to:

CONNECT "localhost:C:\Program Files\Firebird\Firebird_2_5\examples\empbuild\employee.fdb" user SYSDBA password masterkey;

Which resulted in:

Statement failed, SQLSTATE = 28000
cannot attach to password database

After confirming I had the right directory path I decided to give on on connecting for now and try creating a new DB:

SQL>CREATE DATABASE 'C:\data\test.fdb' page_size 8192
CON>user 'SYSDBA' password 'masterkey';

Which also gave me the error:

Statement failed, SQLSTATE = 08001
unavailable database

Are there any common pitfalls I might be hitting? I've also tried the commands above both with and without the firebird service running. Also is there a detailed reference on the SQLSTATE codes?

Luke Chamberlain
  • 430
  • 2
  • 5
  • 17
  • 1
    Besides checking that the service is actually starting (look for an fb_inet_server.exe process or something similar starting) I would check firewalls -- can you connect to port 3050 ok on your machine? – nater Mar 17 '14 at 22:01
  • 2
    Are you running Firebird as a service, or as an application? Does the user executing it have sufficient rights to the Firebird folder? – Mark Rotteveel Mar 18 '14 at 07:41
  • @nater I was able to telnet to that port, that should be enough? – Luke Chamberlain Mar 18 '14 at 14:28
  • @MarkRotteveel It's running as an application. The user does have enough rights and I also tried running ISQL as an admin – Luke Chamberlain Mar 18 '14 at 14:31
  • 2
    If firebird is running as app, it needs to run with admin rights if installed in program files. Otherwise it doesn't have enough rights to write to the db (and the password db). – Mark Rotteveel Mar 18 '14 at 14:55
  • @MarkRotteveel Perfect! Running the app as admin worked. Any chance you know of a reference for the SQLSTATEs? – Luke Chamberlain Mar 18 '14 at 19:19
  • 1
    http://www.firebirdsql.org/rlsnotesh/rlsnotes25.html#rnfb25-appx-sqlstates or otherwise the SQL:2011 standard (Foundation and CLI document) – Mark Rotteveel Mar 19 '14 at 07:35

2 Answers2

16

As already mentioned in my comments the problem is caused by running the Firebird server as an application. Firebird has its password database (security2.fdb) in C:\Program Files\Firebird\Firebird_2_5. As this database is (almost, but not entirely) a normal Firebird database, the server requires write access to this database (for the transactions, etc).

By default (with UAC) users do not have write access to the password database, so this requires elevation to Administrator. So access to Firebird requires that you either run the application as a service with sufficient rights (eg as done by the default installer), or when running the server as application to run it 'As administrator'. Another option is to not install it in Program Files.

This BTW applies double when accessing the example employee database as this database file is also located in the Program Files folder.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Thanks again for your help, I just realized that running as an admin did solve the unavailable database errors but did not solve the 'cannot attach to password database' error, which i also receive when trying to connect with the JDBC driver. – Luke Chamberlain Mar 19 '14 at 14:18
  • 1
    Just also wanted to add that I later ran as a service and had none of the above issues. – Luke Chamberlain Apr 17 '14 at 13:45
  • Inside `firebird/bin` do `sudo ./isql`, then `CONNECT ../examples/empbuild/employee.fdb;` – jacktrades Feb 26 '20 at 12:12
  • @jacktrades The problem of the question was about Windows, and so is my answer. Trying to use sudo on Windows will only yield an error. – Mark Rotteveel Feb 26 '20 at 13:12
0

This is for macOS/OSX (mine is 10.15) firebird ver 2.5 users.

  1. The installation process here does not ask for a sysdba password. Which means: the security database 'security2.fdb' does not exist after a new installation.

This seems to be intentionally for security reasons since > ver 2.5.

  1. To create one, we use the demo database as a helper:

open sql as su: >sudo isql (we don't have user rights on dir)

  1. Connect to a existing db:

sql>connect "/Library/Frameworks/Firebird.framework/Resources/examples/empbuild/employee.fdb " user 'SYSDBA' password 'masterkey';

Now we created the missing file 'security2.fdb' in the folder:

"/Library/Frameworks/Firebird.framework/Resources/English.lproj/var/"

(jro)

JCBiggar
  • 2,477
  • 3
  • 20
  • 33
pro
  • 1