Rails 3: PostgreSQL access denied after renaming app - ruby-on-rails-3

I just renamed my application (replacing all instances of the old name with the new one), and now my application can no longer connect to the postgres database running on localhost.
PG::Error (could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
Any ideas?
Thanks :-----)
EDIT: This is my database.yml
common: &common
adapter: postgresql
username: <username>
password: <password>
development:
<<: *common
database: development
test:
<<: *common
database: test
production:
<<: *common
database: production
Where username and password are the username and credentials for my postgres installation. However, I can't connect to the server using pgAdmin either!

I found the answer: Apparently my postgres server wasn't running locally, so I had to manually start the Service. :-)

Related

In postgresql, copy a view from one database on remote server to a table on local server

I have a remote postgresql server running with views in one of the schema. I need to copy the data from a view in the remote database server and put it in a new table in my local database server
Assume
remote
remote host: hostA
remote port: 5432
remote db: dbA
remote schema: schemaA
remote user: userA
remote password: passA
local
local host: hostB
local port: 5432
local db: dbB
local schema: schemaB
local user: userB
local password: passB

Connection refused when trying to use drush migrate-upgrade with DDEV (Drupal 7 to 8 upgrade)

I'm trying to use DDEV to locally test an upgrade of my running clubs's Drubal 7 website.
I've got one container with a copy of the website, result below is from the DDEV describe command:
URLs
----
https://drupalTest.ddev.site:8003
https://127.0.0.1:32773
http://drupalTest.ddev.site:8002
http://127.0.0.1:32774
MySQL/MariaDB Credentials
-------------------------
Username: "db", Password: "db", Default database: "db"
or use root credentials when needed: Username: "root", Password: "root"
Database hostname and port INSIDE container: db:3306
To connect to db server inside container or in project settings files:
mysql --host=db --user=db --password=db --database=db
Database hostname and port from HOST: 127.0.0.1:32771
To connect to mysql from your host machine,
mysql --host=127.0.0.1 --port=32771 --user=db --password=db --database=db
Other Services
--------------
MailHog (https): https://drupalTest.ddev.site:8026
MailHog: http://drupalTest.ddev.site:8025
phpMyAdmin (https): https://drupalTest.ddev.site:8037
phpMyAdmin: http://drupalTest.ddev.site:8036
I also have a container with Drupal 8 (fresh install).
URLs
----
https://drupal8migration.ddev.site:8017
https://127.0.0.1:32769
http://drupal8migration.ddev.site:8016
http://127.0.0.1:32770
MySQL/MariaDB Credentials
-------------------------
Username: "db", Password: "db", Default database: "db"
or use root credentials when needed: Username: "root", Password: "root"
Database hostname and port INSIDE container: db:3306
To connect to db server inside container or in project settings files:
mysql --host=db --user=db --password=db --database=db
Database hostname and port from HOST: 127.0.0.1:32797
To connect to mysql from your host machine,
mysql --host=127.0.0.1 --port=32797 --user=db --password=db --database=db
Other Services
--------------
MailHog (https): https://drupal8migration.ddev.site:8026
MailHog: http://drupal8migration.ddev.site:8025
phpMyAdmin (https): https://drupal8migration.ddev.site:8037
phpMyAdmin: http://drupal8migration.ddev.site:8036
I'm having problems getting the drush migrate-upgrade command to work, this is the
ddev exec drush migrate-upgrade --legacy-db-url=mysql://db:db#127.0.0.1:32771/db --legacy-root=https://drupalTest.ddev.site:8003 --configure-only
Just getting this error:
SQLSTATE[HY000] [2002] Connection refused [error]
Any help appreciatd
Welcome to ddev, Mark!
Your problem is thtat you're using the wrong --legacy-db-url there. The credentials of the database are going to be:
host: container name of the legacy install (like ddev--db) (NOT 127.0.0.1)
Port: does not need to be specified, because it's the default 3306 (inside the docker container space)
So it looks like you want something like this:
ddev exec drush migrate-upgrade --legacy-db-url=mysql://db:db#ddev-drupaltest-db/db --legacy-root=https://drupalTest.ddev.site:8003 --configure-only
See the faq under "Can different projects communicate with each other"
Also, you'll absolutely want to read Migrating from Drupal 6 to Drupal 8 Like a Boss, which helps to understand all these things in the context of migration.
I note that you seem to be using different http ports for different projects - you don't need to do that at all. The normal way to use ddev is for everything to be on ports 80 and 443 (or some other port set if you have conflicts). You do not need to set router_http_port or router_https_port just to run multiple projects on the same host.

Why can't I access to MariaDB with remote client through SSH if I can in local?

I'm trying to connect to database from remote client.
The thing is:
- when I connect to MySQL through SSH (with both SSH and MySQL root for now...), in command line, it works
- when I want to connect to MySQL through SSH with a remote tool (Workbench or TablePlus), with same credentials, it doesn't work
Tool configuration:
* host 127.0.0.1
* port 3306 (preset)
* user: root
* password: :-)
* database name : X
* SSL mode: tried DISABLED, REQUIRED, PREFERRED
* over SSH: CHECKED
* server: my IP
* port: 22
* user: root
* password: :-)
Test => gives "access denied for user 'root'#'localhost'
So my first thought would be to look in MariaDB Grant the remote host but I want to understand well what is going on and what the difference is between this tool and me on PUTTY connecting to SSH and then to MySQL...
Thank you!
Is there a difference? each time, some local connexion is made after a SSH login?
Thanks for your help!
I finally found the solution by reading some stuff
source 1 : Access Denied for User 'root'#'localhost' (using password: YES) - No Privileges?
source 2 : https://tutox.fr/2017/12/14/en-root-pour-mariadb/
source 3 : Access Denied for User 'root'#'localhost' (using password: YES) - No Privileges?
source 4 : https://tutox.fr/2017/12/14/en-root-pour-mariadb/
source 3 (for MySQL) drove me to source 4 (adapted for MariaDB) was the most important, I did
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('new_password');
and then
FLUSH PRIVILEGES()
and not it work.
I still don't understand why the behavior is different from these 2 points of view

Administer postgres from PGAdmin on remote mac using ssh tunnel

I've got PostgreSQL installed on a Ubuntu server and I'm trying to connect to that server using PGAdmin on a remote macbook.
I've created an ssh tunnel -
macbook:~postgres$ ssh -L 5423:localhost:5432 postgres#mydomain.com
And I can connect using psql on the macbook as expected -
macbook:~ me$ psql -U postgres -p 5423 -h localhost
...
postgres=#
In the 'New Server Registration' window on PGAdminIII I'm entering the following credentials
Name - MyServer
Host - localhost
Port - 5423
Maintenance DB - postgres
Username - postgres
Password - <remote_postgres_password>
However the connection fails -
Error connecting to the server: FATAL: password authentication failed for user "postgres"
Not sure what's going on here, these seem to be the same credentials I've used for psql.
In your server, choose md5 as password authentication on pg_hba.conf file. For example:
host all all 12.34.67.89 255.255.255.255 md5
While 12.34.67.89 is your remote ip. I'm facing the same problem last week. Hope that helps.

Rake routes fails with Access denied

Trying to run the rake routes command on my remote site, and I get the error message Access denied for user 'xxx'#'localhost' (using password: YES)
The site can access the database, so it's not the settings in database.yml, but it has recently started throwing up Action not found errors after months of working OK. Any thoughts on how I can see the routes so that I can check nothing has been corrupted?
Rails 3.2.3, Ruby 1.8.7, Phusion Passenger.
Had the same issue and just resolved it by setting proper development database configuration options in config/database.yml
development:
adapter: mysql2
encoding: utf8
reconnect: false
database:
pool: 5
username:
password:
socket: /var/run/mysqld/mysqld.sock