noshutdown-ru / vault

Is a plugin for project management system Redmine. Allows you to store various passwords/keys in one place for the project.
https://noshutdown.ru/en/redmine-plugins-vault
46 stars 29 forks source link

Mysql2::Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' #27

Closed srekkas closed 6 years ago

srekkas commented 6 years ago

I am trying install plugin, bet hang at this step

rake redmine:plugins:vault:convert rake aborted! Mysql2::Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) /usr/local/rvm/gems/ruby-2.4.0/gems/mysql2-0.4.9/lib/mysql2/client.rb:89:in connect' /usr/local/rvm/gems/ruby-2.4.0/gems/mysql2-0.4.9/lib/mysql2/client.rb:89:ininitialize' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in new' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:18:inmysql2_connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in new_connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:incheckout_new_connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in acquire_connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:inblock in checkout' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in checkout' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:inblock in connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:inretrieve_connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:113:in retrieve_connection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:87:inconnection' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/model_schema.rb:230:in table_exists?' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/attribute_methods/primary_key.rb:97:inget_primary_key' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/attribute_methods/primary_key.rb:85:in reset_primary_key' /usr/local/rvm/gems/ruby-2.4.0/gems/activerecord-4.2.8/lib/active_record/attribute_methods/primary_key.rb:73:inprimary_key' /usr/local/rvm/gems/ruby-2.4.0/gems/protected_attributes-1.1.4/lib/active_record/mass_assignment_security/attribute_assignment.rb:15:in attributes_protected_by_default' /usr/local/rvm/gems/ruby-2.4.0/gems/protected_attributes-1.1.4/lib/active_model/mass_assignment_security.rb:337:inblock in protected_attributes_configs' /usr/local/rvm/gems/ruby-2.4.0/gems/protected_attributes-1.1.4/lib/active_model/mass_assignment_security.rb:222:in protected_attributes' /usr/local/rvm/gems/ruby-2.4.0/gems/protected_attributes-1.1.4/lib/active_model/mass_assignment_security.rb:126:inblock in attr_protected' /usr/local/rvm/gems/ruby-2.4.0/gems/protected_attributes-1.1.4/lib/active_model/mass_assignment_security.rb:125:in each' /usr/local/rvm/gems/ruby-2.4.0/gems/protected_attributes-1.1.4/lib/active_model/mass_assignment_security.rb:125:inattr_protected' /var/www/html/redmine/app/models/custom_field.rb:38:in <class:CustomField>' /var/www/html/redmine/app/models/custom_field.rb:18:in<top (required)>' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:457:in load' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:457:inblock in load_file' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:647:in new_constants_in' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:456:inload_file' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:354:in require_or_load' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:494:inload_missing_constant' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:184:in const_missing' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:526:inload_missing_constant' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:184:in const_missing' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:526:inload_missing_constant' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:184:in const_missing' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:526:inload_missing_constant' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:184:in const_missing' /var/www/html/redmine/lib/redmine/field_format.rb:108:infield_attributes' /var/www/html/redmine/lib/redmine/field_format.rb:111:in <class:Base>' /var/www/html/redmine/lib/redmine/field_format.rb:57:in' /var/www/html/redmine/lib/redmine/field_format.rb:21:in <module:Redmine>' /var/www/html/redmine/lib/redmine/field_format.rb:20:in<top (required)>' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in require' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:inblock in require' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in load_dependency' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:inrequire' /var/www/html/redmine/lib/redmine.rb:40:in <top (required)>' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:inrequire' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in block in require' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:inload_dependency' /usr/local/rvm/gems/ruby-2.4.0/gems/activesupport-4.2.8/lib

srekkas commented 6 years ago

OS is centos, and database is MariaDB

[root@localhost redmine]# systemctl status mysqld Unit mysqld.service could not be found. [root@localhost redmine]# systemctl status mariadb ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2018-03-07 09:38:34 EET; 3h 44min ago Process: 1054 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 968 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 1053 (mysqld_safe) CGroup: /system.slice/mariadb.service ├─1053 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─1382 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock

Mar 07 09:38:31 localhost.localdomain systemd[1]: Starting MariaDB database server... Mar 07 09:38:31 localhost.localdomain mariadb-prepare-db-dir[968]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done. Mar 07 09:38:31 localhost.localdomain mysqld_safe[1053]: 180307 09:38:31 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. Mar 07 09:38:31 localhost.localdomain mysqld_safe[1053]: 180307 09:38:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql Mar 07 09:38:34 localhost.localdomain systemd[1]: Started MariaDB database server.

noshutdown-ru-user commented 6 years ago

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' Can you show your database settings, show to us ls -l /var/run/mysqld/mysqld.sock for testing you can use our repo https://github.com/noshutdown-ru/vagrant_redmine

srekkas commented 6 years ago

test: adapter: mysql2 encoding: utf8 database: redmine_test pool: 5 username: redmine password: bbb socket: /var/lib/mysqld/mysqld.sock

production: adapter: mysql2 encoding: utf8 database: redmine_production pool: 5 username: redmine password: bbb socket: /var/lib/mysql/mysql.sock

ls -l /var/run/mysqld/mysqld.sock ls: cannot access /var/run/mysqld/mysqld.sock: No such file or directory

ls -l /var/run/mariadb/mariadb.pid -rw-rw---- 1 mysql mysql 5 Mar 7 09:38 /var/run/mariadb/mariadb.pid

noshutdown-ru-user commented 6 years ago

looks your database have strange configuration, in logs it tried to connect to /var/run/mysqld/mysqld.sock in database settings you define /var/lib/mysqld/mysqld.sock, for testing you can switch to SqLite

noshutdown-ru-user commented 6 years ago

like this https://github.com/noshutdown-ru/vagrant_redmine/blob/master/templates/database.yml

srekkas commented 6 years ago

i cannot at a moment, because it runs in production.

"fixed" that with: mkdir /var/run/mysqld ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock

now i get

rake redmine:plugins:vault:convert rake aborted! Mysql2::Error: Access denied for user 'redmine'@'localhost' to database 'redmine_development' /usr/local/rvm/gems/ruby-2.4.0/gems/mysql2-0.4.9/lib/mysql2/client.rb:89:in connect' /usr/local/rvm/gems/ruby-2.4.0/gems/mysql2-0.4.9/lib/mysql2/client.rb:89:ininitialize'

noshutdown-ru-user commented 6 years ago

looks user 'redmine'@'localhost' not have access

srekkas commented 6 years ago

but how can it work without what permissions. Redmine runs like half year now. Many issues, we have like 10 users :)

noshutdown-ru-user commented 6 years ago

it tried use database redmine_development maybe your redmine work in production

srekkas commented 6 years ago

hell, well i need break from work long ago.

i have only these databases | redmine_production | | redminedb

noshutdown-ru-user commented 6 years ago

When you run rake redmine:plugins:vault:convert you not define RAILS_ENV example: RAILS_ENV=production bundle exec rake db:migrate

srekkas commented 6 years ago

so i dont want mess anything up, i dont use ruby for anything than redmine. what exact commands i need to run?

run rake redmine:plugins:vault:convert RAILS_ENV=production ??

noshutdown-ru-user commented 6 years ago

When you run rake you need before define environment RAILS_ENV=production, before rake call

noshutdown-ru-user commented 6 years ago

Sorry it doesn't matter , just define RAILS_ENV=production

srekkas commented 6 years ago

so if where are more noobs like me, seems both work

[root@localhost redmine]# rake redmine:plugins:vault:convert RAILS_ENV=production

or

[root@localhost redmine]# export RAILS_ENV=production [root@localhost redmine]# rake redmine:plugins:vault:convert

noshutdown-ru-user commented 6 years ago

just,rake redmine:plugins:vault:convert RAILS_ENV=production but i cannot understand what you tried to do

srekkas commented 6 years ago
Use Redmine encryption Recommended. Don't forget to put your key into database_cipher_key in config/configuration.yml. IMPORTANT: run rake redmine:plugins:vault:convert after changing this switch.
noshutdown-ru-user commented 6 years ago

before you used Vault encryption ? if you not used it - you no need run it

srekkas commented 6 years ago

its new plugin install,so i like to use thats Recommended. My test entry key changed to something like "aes ..." after that.

noshutdown-ru-user commented 6 years ago

you can delete your test keys end proceed using without convert, just check what new keys decrypted properly

srekkas commented 6 years ago

ok thanks for patience

noshutdown-ru-user commented 6 years ago

you welcome, we need improve our documentation =)