为 Ruby on Rails Database.yml 文件正确配置 MySQL

2022-01-14 00:00:00 ruby-on-rails yaml ruby mysql

我有这个配置:

development:
  adapter: mysql2
  encoding: utf8
  database: my_db_name
  username: root
  password: my_password
  host: mysql://127.0.0.1:3306

我收到了这个错误:

Unknown MySQL server host 'mysql://127.0.0.1:3306' (1)

有什么明显的我做错了吗?

Is there something obvious that I am doing incorrectly?

推荐答案

你应该把主机和端口号分开.你可以有一些东西,比如:

You should separate the host from the port number. You could have something, like:

development:
  adapter: mysql2
  encoding: utf8
  database: my_db_name
  username: root
  password: my_password
  host: 127.0.0.1
  port: 3306

相关文章