Comments on What does this failure involving mysql on Mac mean?
Parent
What does this failure involving mysql on Mac mean? Question
I had to reinstall mysql
on my Mac, and after some thrashing I was able to again connect to my Qpixel database from the command line. The data is as expected, so it appears that mysql
itself is ok. Specifically, this worked (connection command and data validation):
$ mysql -u root -p qpixel_dev
mysql> select count(id) from users;
+-----------+
| count(id) |
+-----------+
| 9 |
+-----------+
1 row in set (0.00 sec)
When I run the Qpixel server I get this error:
$ rails s
/Users/cellio/.rvm/gems/ruby-3.0.6/gems/mysql2-0.5.4/lib/mysql2.rb:36:in `require': dlopen(/Users/cellio/.rvm/gems/ruby-3.0.6/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib (LoadError)
And the rest of the stack trace in case it's helpful:
Referenced from: <C48E75F7-C7A1-3D51-A669-683DF84DA6AE> /Users/cellio/.rvm/gems/ruby-3.0.6/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle
Reason: tried: '/opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib' (no such file), '/opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib' (no such file), '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/mysql/9.0.1/lib/libmysqlclient.21.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/mysql/9.0.1/lib/libmysqlclient.21.dylib' (no such file), '/opt/homebrew/Cellar/mysql/9.0.1/lib/libmysqlclient.21.dylib' (no such file), '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file, not in dyld cache) - /Users/cellio/.rvm/gems/ruby-3.0.6/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/mysql2-0.5.4/lib/mysql2.rb:36:in `<top (required)>'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/bundler-2.4.13/lib/bundler/runtime.rb:60:in `require'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/bundler-2.4.13/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/bundler-2.4.13/lib/bundler/runtime.rb:55:in `each'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/bundler-2.4.13/lib/bundler/runtime.rb:55:in `block in require'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/bundler-2.4.13/lib/bundler/runtime.rb:44:in `each'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/bundler-2.4.13/lib/bundler/runtime.rb:44:in `require'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/bundler-2.4.13/lib/bundler.rb:187:in `require'
from /Users/cellio/Data/codidact/qpixel/config/application.rb:7:in `<top (required)>'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/railties-7.0.8.4/lib/rails/commands/server/server_command.rb:137:in `require'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/railties-7.0.8.4/lib/rails/commands/server/server_command.rb:137:in `block in perform'
from <internal:kernel>:90:in `tap'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/railties-7.0.8.4/lib/rails/commands/server/server_command.rb:134:in `perform'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/railties-7.0.8.4/lib/rails/command/base.rb:87:in `perform'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/railties-7.0.8.4/lib/rails/command.rb:48:in `invoke'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/railties-7.0.8.4/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/cellio/Data/codidact/qpixel/bin/rails:9:in `require'
from /Users/cellio/Data/codidact/qpixel/bin/rails:9:in `<top (required)>'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `load'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/spring-4.0.0/lib/spring/client/rails.rb:30:in `call'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/spring-4.0.0/lib/spring/client/command.rb:7:in `call'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/spring-4.0.0/lib/spring/client.rb:30:in `run'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/spring-4.0.0/bin/spring:49:in `<top (required)>'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `load'
from /Users/cellio/.rvm/gems/ruby-3.0.6/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/cellio/Data/codidact/qpixel/bin/spring:12:in `require'
from /Users/cellio/Data/codidact/qpixel/bin/spring:12:in `block in <top (required)>'
from <internal:kernel>:90:in `tap'
from /Users/cellio/Data/codidact/qpixel/bin/spring:9:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
I tried reverting Gemfile
to the version before a recent Dependabot update, just in case, and that didn't make a difference. Rails seems to be complaining about a gem named mysql2-0.5.4
, which has been in Gemfile for more than a year.
I haven't changed Ruby version since the last code change that required it (a long time ago). rvm
does not seem to know about a newer version (for the Mac) than 3.0.6, what I'm using.
I'm stumped. How do I diagnose this and fix or work around it? This is for my development environment, not a production system. I've had to locally edit Gemfile before, so local overrides are ok if needed. But I don't know where I need to poke at what.
Post
It looks like you are using a database user root
. I suspect this is at least part of the problem, so I recommend fixing it first.
If you look in the QPixel repository at the file config/database.yml
you should see the database username and password that QPixel is trying to connect with (for me it's lines 8 and 9):
username: qpixel
password: redacted
If you set up a database user called qpixel
and set a password that you then add to config/database.yml
, then QPixel should be able to connect to the database.
The instructions for doing this are in the section "Setting up the Database" in the installation instructions for QPixel. Since you have already set up QPixel in the past, but then reinstalled MySQL, you may need to repeat some of these steps if things are missing (even though you already did them when you first set up QPixel).
For example, your config files should all still be intact, but contents of the database such as tables and users may need to be created again (they may not - I'm unsure, so I recommend setting up the qpixel
database user and then seeing if that's enough before repeating any other steps).
1 comment thread