[英]Access denied to mysql database as root in rails app
I am running a rails app with mysql. 我正在使用mysql运行Rails应用程序。 My computer shut down in an unorthodox way and now when I am trying to run
rails s
I get Access denied for user 'root'@'localhost' (using password: NO)
我的计算机以非常规的方式关闭,现在当我尝试运行
rails s
我得到Access denied for user 'root'@'localhost' (using password: NO)
My database.yml file looks like : 我的database.yml文件如下所示:
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
socket: /tmp/mysql.sock
development:
<<: *default
database: or_deco__site_development
when Im trying to launch mysql server as root with mysql start
I get this trace : 当我试图以
mysql start
作为root启动mysql服务器时,我得到了以下跟踪信息:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61 "Connection refused")
when I try mysqld --user=mysql as why suggested on mysql website I get this trace:
2017-06-07 18:10:54 140735296021248 [Note] mysqld (mysqld 10.1.19-MariaDB) starting as process 1462 ...
2017-06-07 18:10:54 140735296021248 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2017-06-07 18:10:54 140735296021248 [Warning] One can only use the --user switch if running as root
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: The InnoDB memory heap is disabled
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: Compressed tables use zlib 1.2.5
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: Using SSE crc32 instructions
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-06-07 18:10:54 140735296021248 [Note] InnoDB: Completed initialization of buffer pool
2017-06-07 18:10:55 140735296021248 [Note] InnoDB: Highest supported file format is Barracuda.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'mysql/gtid_slave_pos'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"mysql"."gtid_slave_pos"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'mysql/innodb_index_stats'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"mysql"."innodb_index_stats"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'mysql/innodb_table_stats'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"mysql"."innodb_table_stats"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/active_admin_comments'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."active_admin_comments"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/administrators'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."administrators"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/ar_internal_metadata'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."ar_internal_metadata"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/carousels'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."carousels"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/contacts'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."contacts"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/headers'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."headers"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/images'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."images"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/schema_migrations'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."schema_migrations"', ignored.
2017-06-07 18:10:55 7fff7d53a300 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/sections'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [ERROR] InnoDB: Tablespace open failed for '"or_deco__site_development"."sections"', ignored.
2017-06-07 18:10:55 140735296021248 [Note] InnoDB: 128 rollback segment(s) are active.
2017-06-07 18:10:55 140735296021248 [Note] InnoDB: Waiting for purge to start
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Failed to find tablespace for table '"mysql"."innodb_table_stats"' in the cache. Attempting to load the tablespace with space id 1.
2017-06-07 18:10:55 127a27000 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Could not find a valid tablespace file for 'mysql/innodb_table_stats'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Failed to find tablespace for table '"mysql"."innodb_index_stats"' in the cache. Attempting to load the tablespace with space id 2.
2017-06-07 18:10:55 127a27000 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Could not find a valid tablespace file for 'mysql/innodb_index_stats'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Failed to find tablespace for table '"or_deco__site_development"."images"' in the cache. Attempting to load the tablespace with space id 27.
2017-06-07 18:10:55 127a27000 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/images'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Failed to find tablespace for table '"or_deco__site_development"."carousels"' in the cache. Attempting to load the tablespace with space id 13.
2017-06-07 18:10:55 127a27000 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/carousels'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Failed to find tablespace for table '"or_deco__site_development"."schema_migrations"' in the cache. Attempting to load the tablespace with space id 4.
2017-06-07 18:10:55 127a27000 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2017-06-07 18:10:55 4959924224 [ERROR] InnoDB: Could not find a valid tablespace file for 'or_deco__site_development/schema_migrations'. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html for how to resolve the issue.
2017-06-07 18:10:55 140735296021248 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.32-79.0 started; log sequence number 2135725
2017-06-07 18:10:55 4961533952 [Note] InnoDB: Dumping buffer pool(s) not yet started
2017-06-07 18:10:55 140735296021248 [Note] Plugin 'FEEDBACK' is disabled.
2017-06-07 18:10:55 140735296021248 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2017-06-07 18:10:55 140735296021248 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2017-06-07 18:10:55 140735296021248 [Note] Server socket created on IP: '::'.
2017-06-07 18:10:55 140735296021248 [ERROR] Can't start server : Bind on unix socket: Address already in use
2017-06-07 18:10:55 140735296021248 [ERROR] Do you already have another mysqld server running on socket: /tmp/mysql.sock ?
2017-06-07 18:10:55 140735296021248 [ERROR] Aborting
What should I do to fix this ? 我应该怎么做才能解决这个问题?
EDIT 编辑
After looking around, I tried numerous things: 环顾四周后,我尝试了很多事情:
1) I tried to stop all mysql running processes I still have one process that I cant kill because the pid is constantly changing 1)我试图停止所有mysql正在运行的进程,但我仍然无法杀死一个进程,因为pid一直在变化
ps aux |grep mysql
davidgeismar 19342 0.0 0.0 2432772 532 s000 R+ 7:00PM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysql
2) I also tried creating the mysql.sock file in /tmp as my original error message was : ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61 "Connection refused")
without more success 2)我也尝试在/ tmp中创建mysql.sock文件,因为我的原始错误消息是:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61 "Connection refused")
没有更多的成功
3) I tried desinstalling and reinstalling mysql via homebrew several times 3)我尝试通过自制软件多次卸载并重新安装mysql
4) I also checked the rights on cd /usr/local/Cellar/mysql/5.7.18_1/
and Im getting this : 4)我还检查了
cd /usr/local/Cellar/mysql/5.7.18_1/
上的权限,我得到了这个:
-rw-r--r-- 1 _mysql _mysql 17987 Mar 18 08:56 COPYING
-rw-r--r-- 1 _mysql _mysql 1234 Jun 9 18:27 INSTALL_RECEIPT.json
-rw-r--r-- 1 _mysql _mysql 2478 Mar 18 08:56 README
drwxr-xr-x 42 _mysql _mysql 1428 Jun 9 18:27 bin
drwxr-xr-x 2 _mysql _mysql 68 Jun 9 18:51 data
-rw-r--r-- 1 _mysql _mysql 543 Jun 9 18:27 homebrew.mxcl.mysql.plist
drwxr-xr-x 3 _mysql _mysql 102 Mar 18 08:56 include
drwxr-xr-x 9 _mysql _mysql 306 Mar 18 08:56 lib
drwxr-xr-x 3 _mysql _mysql 102 Mar 18 08:56 scripts
drwxr-xr-x 6 _mysql _mysql 204 Mar 18 08:56 share
drwxr-xr-x 6 _mysql _mysql 204 Jun 9 18:27 support-files
everything seems to be owned by mysql which is supposed to be the correct permissions from what I read... 一切似乎都由mysql拥有,应该是我阅读的正确权限...
I really dont know what to do next. 我真的不知道下一步该怎么做。
Access denied for user 'root'@'localhost' (using password: NO)
用户'root'@'localhost'的访问被拒绝(使用密码:NO)
You should supply the password of the DB in the database.yml
file that is associated with the username root 您应该在与用户名root关联的
database.yml
文件中提供database.yml
的密码。
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: Your_DB_Password_Here
socket: /tmp/mysql.sock
development:
<<: *default
database: or_deco__site_development
Update: 更新:
You should set password to a root user and use that in database.yml
. 您应该将密码设置为root用户,并在
database.yml
使用该密码 。 Try the below to set the password. 请尝试以下设置密码。
$ mysql -u root -p
mysql> SET PASSWORD FOR 'root'@'localhost' = 'your_password_here'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.