代码之家  ›  专栏  ›  技术社区  ›  Jwan622

mysql命令在没有-u根的rails中不起作用

  •  -1
  • Jwan622  · 技术社区  · 6 年前

    我似乎不能用mysql检查我的数据库,我是一个有点新的,我不知道怎么做,即使在阅读了相关的文章。

    Rails 4.1.5 适配器gem是 gem 'mysql2', '~> 0.3.0' .

    mysql --version
    mysql  Ver 14.14 Distrib 5.7.23,
    

    我想继续讨论这个问题,因为现在很难改变传统的应用程序。

    这是我的数据库.yml:

    development:
      adapter: mysql2
      database: some_development
      username: root
      password:
      host: localhost
      port: 3306
    

    这样做有效:

    mysql -u root -p some_development
    Enter password:
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 47
    Server version: 5.7.23 Homebrew
    
    Copyright (c) 2000, 2018, 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 tables;
    +--------------------------------+
    | Tables_in_some_development |
    +--------------------------------+
    | activities                     |
    | addresses                      |
    | associated_products            |
    

    如果我这样尝试:

    mysql some_development
    ERROR 1045 (28000): Access denied for user 'jwan'@'localhost' (using password: NO)
    

    它失败了。

    1 回复  |  直到 6 年前
        1
  •  1
  •   stuckonrails    6 年前

    mysql-ujwan-psome\u密码部分\u开发

    确保某些密码与database.yml匹配

    当然,有些密码不是字面上的,而是您创建的密码