uninitialized constant MysqlCompat::MysqlRes (using mms2r gem)

前端 未结 25 2157
抹茶落季
抹茶落季 2020-12-02 23:48

moved a rails app of mine onto a new server and had to install a few gem dependencies. However, after installing the mysql gem I get the error, uninitialized constant Mysql

相关标签:
25条回答
  • 2020-12-03 00:17

    This problem appeared with me, after upgrading Ubuntu from 9.10 to 10.04.

    It appears to be a problem with the mysql gem.

    Symptoms: Any use of ActiveRecord that requires a connection to mysql yields a stack trace coming from "uninitialized constant MysqlCompat::MysqlRes"

    I tried a "gem update mysql" and found that I couldn't build native extensions because the compiler can't find the mysql_client library. That library (libmysqlclient.so.16) sits in /usr/lib.

    Fix for ubuntu 10.04:

    As root, I did these:

    apt-get install libmysqlclient-dev
    gem install mysql
    

    I notice that several different people are trying things here and I wonder if we're not locating the root cause.

    Variables that people need to clarify in their answers:

    • operating system version - which version of what are you using?
    • where and how did you install mysql? - people here seem to have installed their mysql from source under /usr/local (I installed mine through the ubuntu packaging system)
    • are you on a 64bit ubuntu or 32bit? (I'm currently on 32 bit.)
    0 讨论(0)
  • 2020-12-03 00:17
    sudo gem install mysql -v 2.7 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 
    

    also worked for me when arch flag and symlinks didnt! THANKS!!

    0 讨论(0)
  • 2020-12-03 00:19

    Setting the proper ARCHFLAGS upon gem (re-)installation helped me.. without any symlinking required:

    http://joergbattermann.tumblr.com/post/181479575/fixing-the-nameerror-uninitialized-constant

    0 讨论(0)
  • 2020-12-03 00:19

    I tried everything else here, but still got the problem. Downgrading from MySQL 5.5 to 5.1 fixed it for me. (Mac OS X 10.6.5)

    0 讨论(0)
  • 2020-12-03 00:20

    Basically the problem is the the dynamic library libmysqlclient can't be found. The above solutions will work, but you need to reapply them any time you rebuild the gem, or when you install a new version of MySQL.

    An alternative approach is to add the MySQL directory containing the library to your dynamic load path. Putting the following in my .bashrc file solved the problem:

    export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
    
    0 讨论(0)
  • 2020-12-03 00:21

    on my Mac OS X 10.6 I did this to install the 2.8.1 gem, which worked perfectly with my MacPorts mysql5-server:

    sudo env ARCHFLAGS="-arch x86_64" gem install mysql
    
    0 讨论(0)
提交回复
热议问题