1
votes

I am able to open the mySQL command line doing the following steps:

depot>mysql -u root
mysql>CREATE DATABASE depot_production DEFAULT CHARACTER SET utf8;
mysql>GRANT ALL PRIVILEGES ON depot_production.* TO 'gotqn' IDENTIFIED BY 'mypass';
mysql>EXIT;

then changing my config/database.yml

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: depot_production
  pool: 5
  username: gotqn
  password: mypass
  host: localhost

and final typing:

gotqn:~/Aptana Projects/depot$mysql depot_production

gives me:

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

I've supposed that I should specified a password but typing:

gotqn:~/Aptana Projects/depot$mysql depot_production mypass

just shows me the some variables information.

I am using:

  1. Rails 3.2.8
  2. mysql Ver 14.14 Distrib 5.5.28, for debian-linux-gnu (x86_64) using readline 6.2
  3. Ubuntu LTS 12.04
3

3 Answers

0
votes

Configuration file config/database.yml is for Ruby, not for mysql command line tool. For command line tool use correct syntax:

mysql --user=user_name --password=your_password db_name

by default it uses your current logged in user if --user=user_name is omited.

0
votes

In database.yml use username as root:

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: depot_production
  pool: 5
  username: root
  password: 
  host: localhost
0
votes

Create the user in mysql as @'localhost'

    mysql>GRANT ALL PRIVILEGES ON depot_production.* TO 'gotqn'@'localhost' IDENTIFIED BY 'mypass';