Can't connect to local Firebird with ISQL

Luke Chamberlain picture Luke Chamberlain · Mar 17, 2014 · Viewed 30k times · Source

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?

Answer

Mark Rotteveel picture Mark Rotteveel · Mar 19, 2014

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.