没有-u根目录,mysql命令在rails中不起作用

时间:2018-10-10 15:13:20

标签: mysql ruby-on-rails

我似乎无法使用mysql检查我的数据库,但是我有点新,即使阅读了相关文章,我也不知道该怎么做。

我在Rails 4.1.5上,而适配器gem是gem 'mysql2', '~> 0.3.0'

mysql版本:

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            |

但是我一直在从根本上做到这一点。该密码是我登录到Mac时使用的密码。这样好吗

如果我这样尝试:

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

失败。

1 个答案:

答案 0 :(得分:1)

mysql -uroot -p

将some_development。*上的所有特权授予“ some_password”标识的“ jwan” @“ localhost”

mysql -ujwan -psome_password some_development

确保some_password与database.yml匹配

当然some_password不是文字,而是您创建的密码