4

I am working through a RoR tutorial from lynda.com for a week already & without changing anything today i was not able to see my content on localhost due to this error :

Mysql2::Error Access denied for user 'simple_cms'@'localhost' (using password: YES)

I do know that this problem has been referred many times befored , i am still not able to find a confirmed solution .

To give you further information regarding my set up my working enviroment is Yosemite 10.10.4 - Rails 3.2.22 - 5.6.22 MySQL - WEBrick 1.3.1

i have set up the SQL database as it looks below on the database.yml file on the config folder of the project

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: simple_cms_development
  pool: 5
  username: simple_cms
  password: **********
  socket: /tmp/mysql.sock


test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: simple_cms_test
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: simple_cms_production
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock

Also i noticed that by trying to connect via terminal on the database with the password

§ mysql -u root -p

and again i get the error ::ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

I tried to restart manually MySQL server from menu & all i got was the same error!

What is the problem and it doesn't let me log in with the settings as i did all this time ?

Is it a problem with rails or with mysql settings?

While everything seems to be as it has to be,do i have to change something on the database.yml file?

5
  • On what port are you running your database? Commented Aug 8, 2015 at 18:12
  • Oh, and try mysql -uroot -p without the space between u and root Commented Aug 8, 2015 at 18:14
  • Thanks for the quick reply, my database runs on 3306 port & after i runned this command mysql -uroot -p i got the same error message as i stated above! Commented Aug 8, 2015 at 18:33
  • What does mysql -uroot -P3306 -p say? Does mysql ask for a Password? Commented Aug 8, 2015 at 18:53
  • Perhaps you did not Need a Password? try mysql -uroot -P3306 Commented Aug 8, 2015 at 18:58

3 Answers 3

1

I finally solved this problem by uninstalling the current MySQL via terminal with the command brew uninstall MySQL & then reinstalling it with brew, from the beginning!

After the installation, when i tried to login into MySQL i did it through the command :mysql -u root -p! At this point on the password request i added the one that has been set up before on the config file :database.yml and it logged in succesfully!

Thanks for the help!

Sign up to request clarification or add additional context in comments.

1 Comment

I have a very similar issue as well when configuring and setting up my app -- also called simple_cms too. :) After you did 'brew install mysql' to reinstall it, did you do anything else or just go with 'mysql -u rails_user -p simple_cms_development then enter the same password you have in database.yml? Because I still get the same password error here.
0

The error-message

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

will Show up if you entered a wrong password. Reset your Password according to this link.

6 Comments

Thank you for your reply , i just found out that when i run the command show databases; the response does not contain the database simple_cms_development.How is this possible to happen by the time i was working on this about a week already?
you can easily check if the databse actually exists: In the filesystem go to your mysql/data Folder. Here a Folder for each database is created. Do you see a Folder named simple_cms_development?
Unfortunately it is not referred there anywhere .. What should i do now ? I am even more confused..
when you can run Show databases and see a result you can connect to your database. Where you run this comand, run a create database simple_cms_development.
mysql> create database simple_cms_development; ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'simple_cms_development' This is the result of this command , does this mean that it actually exists?
|
0

You need to do 3 things :

  1. Check if Mysql Server is On(or Started)
  2. Change the password logging in mysql from terminal.
  3. Create a database in your project folder using:

    $ rake db:create

and that should do it for you so it did for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.