From 1f69658dce8da8a8b5384292e89c2e71cd0ae828 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 5 Mar 2023 15:40:27 -0800 Subject: [PATCH] For databases, especially mysql, connect over 127.0.0.1 IP address When using 'localhost', mysql2 uses the socket. This is an uncommon setup, so use IP instead. --- lib/jekyll-import/importers/drupal_common.rb | 2 +- lib/jekyll-import/importers/easyblog.rb | 2 +- lib/jekyll-import/importers/joomla.rb | 2 +- lib/jekyll-import/importers/joomla3.rb | 2 +- lib/jekyll-import/importers/mephisto.rb | 4 ++-- lib/jekyll-import/importers/mt.rb | 2 +- lib/jekyll-import/importers/roller.rb | 2 +- lib/jekyll-import/importers/s9y_database.rb | 2 +- lib/jekyll-import/importers/textpattern.rb | 2 +- lib/jekyll-import/importers/typo.rb | 2 +- lib/jekyll-import/importers/wordpress.rb | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/jekyll-import/importers/drupal_common.rb b/lib/jekyll-import/importers/drupal_common.rb index ef9046ca..59a78066 100644 --- a/lib/jekyll-import/importers/drupal_common.rb +++ b/lib/jekyll-import/importers/drupal_common.rb @@ -16,7 +16,7 @@ module ClassMethods DEFAULTS = { "engine" => "mysql", "password" => "", - "host" => "localhost", + "host" => "127.0.0.1", "prefix" => "", "port" => "3306", "types" => %w(blog story article), diff --git a/lib/jekyll-import/importers/easyblog.rb b/lib/jekyll-import/importers/easyblog.rb index dfa698ca..8f563fe5 100644 --- a/lib/jekyll-import/importers/easyblog.rb +++ b/lib/jekyll-import/importers/easyblog.rb @@ -32,7 +32,7 @@ def self.process(options) dbname = options.fetch("dbname") user = options.fetch("user") pass = options.fetch("password", "") - host = options.fetch("host", "localhost") + host = options.fetch("host", "127.0.0.1") section = options.fetch("section", "1") table_prefix = options.fetch("prefix", "jos_") diff --git a/lib/jekyll-import/importers/joomla.rb b/lib/jekyll-import/importers/joomla.rb index 65ce3181..2d096c43 100644 --- a/lib/jekyll-import/importers/joomla.rb +++ b/lib/jekyll-import/importers/joomla.rb @@ -33,7 +33,7 @@ def self.process(options) dbname = options.fetch("dbname") user = options.fetch("user") pass = options.fetch("password", "") - host = options.fetch("host", "localhost") + host = options.fetch("host", "127.0.0.1") port = options.fetch("port", 3306).to_i section = options.fetch("section", "1") table_prefix = options.fetch("prefix", "jos_") diff --git a/lib/jekyll-import/importers/joomla3.rb b/lib/jekyll-import/importers/joomla3.rb index 59d424db..4e65c12d 100644 --- a/lib/jekyll-import/importers/joomla3.rb +++ b/lib/jekyll-import/importers/joomla3.rb @@ -33,7 +33,7 @@ def self.process(options) dbname = options.fetch("dbname") user = options.fetch("user") pass = options.fetch("password", "") - host = options.fetch("host", "localhost") + host = options.fetch("host", "127.0.0.1") port = options.fetch("port", 3306).to_i cid = options.fetch("category", 0) table_prefix = options.fetch("prefix", "jos_") diff --git a/lib/jekyll-import/importers/mephisto.rb b/lib/jekyll-import/importers/mephisto.rb index 90cb44bc..a5a55063 100644 --- a/lib/jekyll-import/importers/mephisto.rb +++ b/lib/jekyll-import/importers/mephisto.rb @@ -14,7 +14,7 @@ def self.postgres(c) COPY jekyll TO STDOUT WITH CSV HEADER; ROLLBACK; SQL - command = %(psql -h #{c[:host] || "localhost"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"}) + command = %(psql -h #{c[:host] || "127.0.0.1"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"}) Jekyll.logger.info "Executing:", command `#{command}` CSV.process @@ -61,7 +61,7 @@ def self.process(options) dbname = options.fetch("dbname") user = options.fetch("user") pass = options.fetch("password", "") - host = options.fetch("host", "localhost") + host = options.fetch("host", "127.0.0.1") db = Sequel.mysql2(dbname, :user => user, :password => pass, diff --git a/lib/jekyll-import/importers/mt.rb b/lib/jekyll-import/importers/mt.rb index 1764355e..be8c62c7 100644 --- a/lib/jekyll-import/importers/mt.rb +++ b/lib/jekyll-import/importers/mt.rb @@ -242,7 +242,7 @@ def self.database_from_opts(options) Sequel.sqlite(dbname) when "mysql", "postgres" db_connect_opts = { - :host => options.fetch("host", "localhost"), + :host => options.fetch("host", "127.0.0.1"), :user => options.fetch("user"), :password => options.fetch("password", ""), } diff --git a/lib/jekyll-import/importers/roller.rb b/lib/jekyll-import/importers/roller.rb index 102b70d7..db4e6900 100644 --- a/lib/jekyll-import/importers/roller.rb +++ b/lib/jekyll-import/importers/roller.rb @@ -64,7 +64,7 @@ def self.process(opts) options = { :user => opts.fetch("user", ""), :pass => opts.fetch("password", ""), - :host => opts.fetch("host", "localhost"), + :host => opts.fetch("host", "127.0.0.1"), :port => opts.fetch("port", "3306"), :socket => opts.fetch("socket", nil), :dbname => opts.fetch("dbname", ""), diff --git a/lib/jekyll-import/importers/s9y_database.rb b/lib/jekyll-import/importers/s9y_database.rb index 68b3117c..350699a7 100644 --- a/lib/jekyll-import/importers/s9y_database.rb +++ b/lib/jekyll-import/importers/s9y_database.rb @@ -99,7 +99,7 @@ def self.process(opts) options = { :user => opts.fetch("user", ""), :pass => opts.fetch("password", ""), - :host => opts.fetch("host", "localhost"), + :host => opts.fetch("host", "127.0.0.1"), :port => opts.fetch("port", 3306), :socket => opts.fetch("socket", nil), :dbname => opts.fetch("dbname", ""), diff --git a/lib/jekyll-import/importers/textpattern.rb b/lib/jekyll-import/importers/textpattern.rb index 92f58d5a..1cb95af7 100644 --- a/lib/jekyll-import/importers/textpattern.rb +++ b/lib/jekyll-import/importers/textpattern.rb @@ -37,7 +37,7 @@ def self.process(options) dbname = options.fetch("dbname") user = options.fetch("user") pass = options.fetch("password", "") - host = options.fetch("host", "localhost") + host = options.fetch("host", "127.0.0.1") db = Sequel.mysql2(dbname, :user => user, :password => pass, :host => host, :encoding => "utf8") diff --git a/lib/jekyll-import/importers/typo.rb b/lib/jekyll-import/importers/typo.rb index 77e95c1a..67c42917 100644 --- a/lib/jekyll-import/importers/typo.rb +++ b/lib/jekyll-import/importers/typo.rb @@ -43,7 +43,7 @@ def self.process(options) dbname = options.fetch("dbname") user = options.fetch("user") pass = options.fetch("password", "") - host = options.fetch("host", "localhost") + host = options.fetch("host", "127.0.0.1") FileUtils.mkdir_p "_posts" case server.intern diff --git a/lib/jekyll-import/importers/wordpress.rb b/lib/jekyll-import/importers/wordpress.rb index 4edcd6b6..3984108b 100644 --- a/lib/jekyll-import/importers/wordpress.rb +++ b/lib/jekyll-import/importers/wordpress.rb @@ -81,7 +81,7 @@ def self.process(opts) options = { :user => opts.fetch("user", ""), :pass => opts.fetch("password", ""), - :host => opts.fetch("host", "localhost"), + :host => opts.fetch("host", "127.0.0.1"), :port => opts.fetch("port", "3306"), :socket => opts.fetch("socket", nil), :dbname => opts.fetch("dbname", ""),