ubuntu mysql: Access denied for user 'root'@'localhost'
http://siwei.me/blog/posts/mysql--9
使用这个方法:(参考: https://stackoverflow.com/a/52674808/445908)
sudo mysql -u root
可以正常进入数据库,但是使用rake db:create/migrate不能正常进行操作提示user@localhost不正确。
可以创建user然后继续操作:
首先创建了数据库:first_database, first_database_test
Then create a normal user, set a password, then use that user to work.
create user 'user'@'localhost' identified by 'user1234';<br />
grant all on your_database.* to 'user'@'localhost';
(例如: grant all on first_database.* to 'user'@'localhost';)
(grant all on first_database._test* to 'user'@'localhost';)<br />
select host, user from mysql.user;
Then try to access:
mysql -u user -puser1234
然后在config/database.yml修改user和password就可以migrate了
user: user
password: user1234