我正在使用mysql运行rails应用程序。
我的计算机以非正统的方式关闭,现在当我尝试运行rails s
时,我得到Access denied for user 'root'@'localhost' (using password: NO)
我的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
当我尝试以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
我该怎么做才能解决这个问题?
修改
环顾四周后,我尝试了很多东西:
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)我也尝试在/ tmp中创建mysql.sock文件,原始错误信息为:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61 "Connection refused")
没有更多的成功
3)我尝试通过自制程序多次卸载并重新安装mysql
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
一切似乎都归mysql所有,它应该是我读过的正确权限......
我真的不知道接下来该做什么。
答案 0 :(得分:0)
拒绝访问用户&root;&#39; @&#39; localhost&#39; (使用密码:否)
您应该在与{em>用户名root
相关联的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
<强> 更新 强>
您应为root用户设置密码并在database.yml
中使用该密码。请尝试以下设置密码。
$ mysql -u root -p
mysql> SET PASSWORD FOR 'root'@'localhost' = 'your_password_here'