# Connect Amber to Postgress

**URL:** <https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956>\
**Category:** Help & Support\
**Created:** [October 18, 2021, 4:02am UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956 "2021-10-18T04:02:30Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 18, 2021, 7:56pm UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/21 "2021-10-18T19:56:35Z")

</div>

I have a master password for pgadmin, but I don’t know of any other password.

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 18, 2021, 7:57pm UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/22 "2021-10-18T19:57:53Z")

</div>

I changed password to postgress, still doesn’t work

---

<div class="post-metadata">

**Author:** ![henrikac](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/henrikac/32/3079_2.png) [@henrikac](https://forum.crystal-lang.org/u/henrikac)\
**Post date:** [October 18, 2021, 8:05pm UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/23 "2021-10-18T20:05:02Z")

</div>

No idea what the issue is then.

- Do you have a user with the username **postgres** or is it named something else?
- Is it running on the correct port?

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 18, 2021, 8:06pm UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/24 "2021-10-18T20:06:52Z")

</div>

I don’t know I just installed it. I’d think everything would be default.

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 19, 2021, 1:09am UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/25 "2021-10-19T01:09:54Z")

</div>

I purged and reinstalled Postges, now I get this:

```auto
no driver was registered for the schema "", did you maybe forget to require the database driver?

```

how do I set up a driver?

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 19, 2021, 5:25pm UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/26 "2021-10-19T17:25:38Z")

</div>

do I need to use a database shard? should I look at this?  
[https://crystal-lang.org/reference/database/](https://crystal-lang.org/reference/database/)

---

<div class="post-metadata">

**Author:** ![orangeSi](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/orangesi/32/1569_2.png) [@orangeSi](https://forum.crystal-lang.org/u/orangeSi)\
**Post date:** [October 20, 2021, 3:23am UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/27 "2021-10-20T03:23:33Z")

</div>

0.I run below in my Centos system not Ubuntu and works well:

1.If you had install Postgresql, you can try replace `peer` or `ident` in /var/lib/pgsql/data/pg\_hba.conf to `md5` and then restart Postgresql by `sudo service postgresql restart`. ([postgresql - psql: FATAL: Ident authentication failed for user "postgres" - Stack Overflow](https://stackoverflow.com/questions/2942485/psql-fatal-ident-authentication-failed-for-user-postgres)).

2.If above still not work, try to modify password to ‘password’ by

```auto
$sudo -u postgres psql
could not change directory to "/home/myth/pet-tracker": Permission denied
psql (10.17)
Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'password';
ALTER ROLE
postgres=# \q

```

To make sure database works, so can try this

```auto
su - postgres 
psql -h localhost -p 5432 --username postgres -d postgres -W # if type 'password' return no error, mean password had ok!

```

3.After above, then run

```auto
amber new pet-tracker
cd pet-tracker
amber g scaffold Pet name:string breed:string age:integer
amber db create migrate

```

as [Getting Started - Amber Framework](https://docs.amberframework.org/amber/getting-started)

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 20, 2021, 4:18am UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/28 "2021-10-20T04:18:06Z")

</div>

That doesn’t sound like the error I get. I’ll share it when I’m back at my computer, but I think it just said connection fail, nothing about Ident .

---

<div class="post-metadata">

**Author:** ![orangeSi](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/orangesi/32/1569_2.png) [@orangeSi](https://forum.crystal-lang.org/u/orangeSi)\
**Post date:** [October 20, 2021, 4:50am UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/29 "2021-10-20T04:50:00Z")

</div>

I got the same connection fail when `abmber db create`, then I went to check by `psql` but get the ` Ident authentication failed`, so I replaced `peer` or `ident` in pg\_hba.conf to `md5` and then restart Postgresql and `abmber db create` works.

If below code works, that means postgresql database connection is successful, and then go to try `amber db create `

```auto
su - postgres 
psql -h localhost -p 5432 --username postgres -d postgres -W # if type 'password' return no error, mean password had ok!

```

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 21, 2021, 6:22pm UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/30 "2021-10-21T18:22:28Z")

</div>

Is this in bash? The first row gives me

```auto
su: Authentication failure

```

I remember i got in before, so I’m not sure what to do.

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 21, 2021, 6:27pm UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/31 "2021-10-21T18:27:12Z")

</div>

```auto
psql -h localhost -p 5432 --username postgres -d postgres -W # if type 'password' return no error, mean password had ok!

```

doesn’t give any errors, but

```auto
amber db create migrate

```

just says

```auto
Connection unsuccessful: postgres://postgres:password@localhost:5432/postgres

```

---

<div class="post-metadata">

**Author:** ![orangeSi](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/orangesi/32/1569_2.png) [@orangeSi](https://forum.crystal-lang.org/u/orangeSi)\
**Post date:** [October 22, 2021, 1:57am UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/32 "2021-10-22T01:57:26Z")

</div>

Had you try below to change password of user postgres ?

```auto
$sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'password';"

```

If so, then restart Postgresql by `sudo service postgresql restart`.

In my opinion, should make sure the password of user postgre is ‘password’ and then Amber can recognise it.

---

<div class="post-metadata">

**Author:** ![BrettKnoss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/brettknoss/32/1119_2.png) [@BrettKnoss](https://forum.crystal-lang.org/u/BrettKnoss)\
**Post date:** [October 22, 2021, 3:16am UTC](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956/33 "2021-10-22T03:16:58Z")

</div>

> [@orangeSi](#):
>
> `sudo service postgresql restart`

It works. For some reason I don’t have the amber logo, but the app itself works

[Previous page](https://forum.crystal-lang.org/t/connect-amber-to-postgress/3956.md?page=1)
