Home>
Be in trouble

I am a beginner.
I am developing a Ruby On Rails application on docker.

When I was messing around with migration, the db seemed to be broken and I couldn't go either. ..
db is mysql.

rails db: drop
rails db: create
rails db: migrate
I tried to remake it from scratch in the order of, but it still didn't work,

rails aborted!
ActiveRecord :: StatementInvalid: Mysql2 :: Error: Got error 168 from storage engine: CREATE TABLE `schema_migrations` (`version` varchar (255) NOT NULL PRIMARY KEY)
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query'
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131: in `block in query'
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt'
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb: 187: in `block (2 levels) in execute'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:581: in `block (2 levels) in log'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:311: in `create_table'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/schema_migration.rb:29:in `create_table'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1187: in `initialize'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `new'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `up'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1011: in `migrate'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/railties/databases.rake:60:in `block (2 levels) in<top (required)>'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/command.rb:48:in `invoke'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands.rb:18:in `<top (required)>'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92: in `register'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291: in `block in require'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `require'
bin/rails: 4: in `<main>'
Caused by:
Mysql2 :: Error: Got error 168 from storage engine
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query'
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:131: in `block in query'
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `handle_interrupt'
/usr/local/bundle/gems/mysql2-0.5.3/lib/mysql2/client.rb:130:in `query'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb: 187: in `block (2 levels) in execute'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:186:in `block in execute'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:581: in `block (2 levels) in log'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:185:in `execute'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/mysql/database_statements.rb:28:in `execute'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:311: in `create_table'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/schema_migration.rb:29:in `create_table'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1187: in `initialize'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `new'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1036:in `up'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/migration.rb:1011: in `migrate'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/tasks/database_tasks.rb:172:in `migrate'
/usr/local/bundle/gems/activerecord-5.2.4.3/lib/active_record/railties/databases.rake:60:in `block (2 levels) in<top (required)>'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/command.rb:48:in `invoke'
/usr/local/bundle/gems/railties-5.2.4.3/lib/rails/commands.rb:18:in `<top (required)>'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92: in `register'
/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'/usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291: in `block in require'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.2.4.3/lib/active_support/dependencies.rb:291:in `require'
bin/rails: 4: in `<main>'
Tasks: TOP =>db: migrate

I get an error like this.

Is there a way to completely reset the db? ..

Development environment

ruby 2.5.3
rails 5.2.4
mysql 5.7

docker-compose.yml

version: '3'
services: services:
  db:
    image: mysql: 5.7
    ports: ports:
        --'2012: 3306'
    environment: environment:
        MYSQL_USER: root
        MYSQL_ROOT_PASSWORD: password
    volumes:
        --./db/mysql/volumes:/var/lib/mysql
  web:
    image: rails: my_orav3
    command: bash -c "rm -f tmp/pids/server.pid&&bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      --.:/Myapp
    environment: environment:
      --TNS_ADMIN = ./oracle_conf
      --TZ = "Asia/Tokyo"
      --LANG = ja_JP.UTF-8
    ports: ports:
      -"2102: 3000"
    depends_on:
      --db
  • Answer # 1

    I solved it by deleting mysql/and creating db: create.

  • Answer # 2

    If it's okay to erase everything, it's a reinstall of MySQL.