Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115528
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:35:36+00:00 2026-05-20T22:35:36+00:00

What I am surmising is that mysql2 does not default to a TCP connection

  • 0

What I am surmising is that mysql2 does not default to a TCP connection protocol when I remove the socket parameter. Do you guys agree? Any GEM suggestions?

I can connect via the mysql command line. So yep all configured from a mysql point of view.

This line connects nicely: “mysql -P 3406 -u userid -p –protocol=TCP -h localhost”
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 77402
Server version: 5.0.77-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+---------------------+
| Database            |
+---------------------+

database.yml

svc_development:
    adapter: mysql2
    encoding: utf8
    database: my_db
    username: userid
    password: apasswd
    host: localhost
    port: 3406  

The port is correct for this instance. I am connecting to this database via SSH tunnel “-L 3406:host:3306”
I looked at themysql2 code, it does not take a protocol parameter. It just uses socket.

Model: looky_loo.rb

class LookyLoo < ActiveRecord::Base
    self.abstract_class = true
    establish_connection  "svc_development"
end

From Rails console

from script/rails:6:in `<main>'ruby-1.9.2-p136 :002 > LookyLoo.all
Mysql2::Error: Access denied for user 'userid'@'localhost' (using password: YES)
    from /Users/michael.pechner/.rvm/gems/ruby-1.9.2-p136@amqp/gems/mysql2-0.2.7/lib/mysql2/client.rb:42:in `connect'
    from /Users/michael.pechner/.rvm/gems/ruby-1.9.2-p136@amqp/gems/mysql2-0.2.7/lib/mysql2/client.rb:42:in `initialize'
    from /Users/michael.pechner/.rvm/gems/ruby-1.9.2-p136@amqp/gems/mysql2-0.2.7/lib/active_record/connection_adapters/mysql2_adapter.rb:14:in `new'
    from /Users/michael.pechner/.rvm/gems/ruby-1.9.2-p136@amqp/gems/mysql2-0.2.7/lib/active_record/connection_adapters/mysql2_adapter.rb:14:in `mysql2_connection'
    from /Users/michael.pechner/.rvm/gems/ruby-1.9.2-p136@amqp/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `new_connection'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:35:37+00:00Added an answer on May 20, 2026 at 10:35 pm

    In mysql localhost is “magic” it means use the socket. Try using 127.0.0.1 instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

QUESTION How can I create a MySQL table so, that a field's default value
CodeCampServer source code contains a generic StaticFactory . I'm surmising that this is a
So I have a PHP page that allows users to download CSV for what
I have a MySQL/Rails app that needs search. Here's some info about the data:
I'm wondering how it's possible that jQuery objects show up as an array in
I'm looking for some combination of a plugin or clever programming technique that will
It's surprising how difficult it is to find a simple, concise answer to this
I've just done a test with bitfields, and the results are surprising me. class
I am having trouble understanding the Phing documentation regarding multiple conditions for a given
What's the right way to control timeouts, from the client, when running against a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.