Rails app connecting to MS SQL Server Express on another server - sql

I have developed an application using SQLite (as provided). I've renamed all the columns to fit with the SQL that is running on another server, but cannot get it to connect and to populate with the server database.
My database.yml file looks like this:
production:
adapter: mysql2
host: *IP*
encoding: utf8
reconnect: false
pool: 5
username: *user*
password: *pwd*
database: *DB name*
The IP I use to connect to the server is different to that of the IPv4 address of it, but I've tried both.
I've commented out:
gem 'sqlite3'
and replaced it with
gem 'mysql2', '~> 0.3.11'
Thanks.

Related

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.

Resque to connect to Redis with AUTH

Need some help connecting Resque Web UI (Rack config.ru) to a Redis server with AUTH
Using Resque + Unicorn + Nginx and installed most using apt-get install (Debian) and gem install
So basically Unicorn loads up resque-web (via Rack) using the standard config.ru
http://etagwerker.wordpress.com/2011/06/27/how-to-setup-resque-web-with-nginx-and-unicorn/
#!/usr/bin/env ruby
# Put this in /var/www/resque-web/config.ru
require 'logger'
$LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/lib')
require 'resque/server'
Resque::Server.use Rack::Auth::Basic do |username, password|
password == '{{password}}' # password
end
# Set the RESQUE_CONFIG env variable if you’ve a `resque.rb` or similar
# config file you want loaded on boot.
if ENV['RESQUECONFIG'] && ::File.exists?(::File.expand_path(ENV['RESQUE_CONFIG']))
load ::File.expand_path(ENV['RESQUE_CONFIG'])
end
use Rack::ShowExceptions
run Resque::Server.new
I'm trying to find out how to connect this to a Redis server with AUTH per the documentation here: http://redis.io/topics/security (basically in /etc/redis/redis.conf)
This rack configuration seem to only connection to a "vanilla" Redis server using defaults (localhost with standard 6379 port) -- how do I specify the Redis connection so I can pass the user/pass in the format below
redis://user:PASSWORD#redis-server:6379
I've tried using ENV['RESQUE_CONFIG'] to load up a resque.rb file
require 'resque'
Resque.redis = Redis.new(:password => '{{password}}')
this gets pulled via /etc/unicorn/resque-web.conf
# Put this in /etc/unicorn/resque-web.conf
RAILS_ROOT=/var/www/resque-web
RAILS_ENV=production
RESQUE_CONFIG=/var/www/resque-web/config/resque.rb
but it's still not really working
BTW, everything works without the Redis AUTH and just using the "vanilla" localhost Redis connection
Try this
redis_client = Redis.new(:url => "redis://user:PASSWORD#redis-server:6379")
and then do this
Resque.redis = redis_client
Hope this help

ERROR Unkown database: DATABASE_URL after overriding the DATABASE_URL in the heroku app

I am trying to connect two Heroku apps to one database. So I overrided the DATABASE_URL. now the heroku config as:
=== muse-me Config Vars
DATABASE_URL: postgres://rbbcoxizviewiu:taJsBZf...
GEM_PATH: vendor/bundle/ruby/1.9.1
HEROKU_POSTGRESQL_OLIVE_URL: postgres://jnlltenwyvmdup:Q5Doaw...
LANG: en_US.UTF-8
PATH: bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
RACK_ENV: production
RAILS_ENV: production
Then I run
heroku pg:psql DATABASE_URL
It gave me an error:
! Unknown database: DATABASE_URL. Valid options are: HEROKU_POSTGRESQL_OLIVE_URL
What should I do? Do I really connect to the database with the DATABASE_URL?
Thanks
"DATABASE_URL" is just a placeholder for "HEROKU_POSTGRESQL_OLIVE_URL". If you run:
heroku pg:psql HEROKU_POSTGRESQL_OLIVE_URL
That should work because you're explicitly telling pg which database url to use. To be able to use that command without specifying the db, you need to promote it to be your primary db:
heroku pg:promote HEROKU_POSTGRESQL_OLIVE_URL
heroku pg:psql
More info on promote is located here: https://devcenter.heroku.com/articles/heroku-postgresql#pgpromote
When running
heroku pg:psql DATABASE_URL
heroku tries to connect to the URL : DATABASE_URL, which obviously doesn't exist, it does read the ENV var DATABASE_URL
So if you're in the folder of your app, simply running
heroku pg:psql
is enough, otherwise, you can specify the app
heroku pg:psql --app <YOUR_APP>
And then heroku will read the DATABASE_URL var from the app it's connecting on.

Rails 3: PostgreSQL access denied after renaming app

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. :-)

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