Valet: Cannot connect to MySQL server ([2002] Connection refused)

Created on 10 Jul 2017  路  2Comments  路  Source: laravel/valet

Every time i reboot my MacOS connection to MySQL server is lost. I have tried running

brew services start mysql // ==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
mysql start // ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
mysqld start  // output below

[admin:~]$ mysqld start
2017-07-10T07:32:08.656057Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-10T07:32:08.656278Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2017-07-10T07:32:08.656327Z 0 [Note] mysqld (mysqld 5.7.18) starting as process 3573 ...
2017-07-10T07:32:08.658956Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2017-07-10T07:32:08.660222Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-10T07:32:08.660236Z 0 [Note] InnoDB: Uses event mutexes
2017-07-10T07:32:08.660239Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-07-10T07:32:08.660243Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-10T07:32:08.660520Z 0 [Note] InnoDB: Number of pools: 1
2017-07-10T07:32:08.660651Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-07-10T07:32:08.661705Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-07-10T07:32:08.670189Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-07-10T07:32:08.686714Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-07-10T07:32:08.696762Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-07-10T07:32:08.696876Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-07-10T07:32:08.704515Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-07-10T07:32:08.705145Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-07-10T07:32:08.705158Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-07-10T07:32:08.705351Z 0 [Note] InnoDB: Waiting for purge to start
2017-07-10T07:32:08.756830Z 0 [Note] InnoDB: 5.7.18 started; log sequence number 3325670
2017-07-10T07:32:08.757282Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/var/mysql/ib_buffer_pool
2017-07-10T07:32:08.757754Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-07-10T07:32:08.764340Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170710  9:32:08
2017-07-10T07:32:08.770132Z 0 [ERROR] Too many arguments (first extra is 'start').
2017-07-10T07:32:08.770150Z 0 [Note] Use --verbose --help to get a list of available options!
2017-07-10T07:32:08.770153Z 0 [ERROR] Aborting

2017-07-10T07:32:08.770158Z 0 [Note] Binlog end
2017-07-10T07:32:08.770195Z 0 [Note] Shutting down plugin 'validate_password'
2017-07-10T07:32:08.770201Z 0 [Note] Shutting down plugin 'ngram'
2017-07-10T07:32:08.770203Z 0 [Note] Shutting down plugin 'partition'
2017-07-10T07:32:08.770206Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2017-07-10T07:32:08.770209Z 0 [Note] Shutting down plugin 'ARCHIVE'
2017-07-10T07:32:08.770211Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2017-07-10T07:32:08.770240Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2017-07-10T07:32:08.770244Z 0 [Note] Shutting down plugin 'MyISAM'
2017-07-10T07:32:08.770269Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2017-07-10T07:32:08.770273Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2017-07-10T07:32:08.770276Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2017-07-10T07:32:08.770278Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2017-07-10T07:32:08.770281Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2017-07-10T07:32:08.770284Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2017-07-10T07:32:08.770286Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2017-07-10T07:32:08.770289Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2017-07-10T07:32:08.770305Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2017-07-10T07:32:08.770309Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2017-07-10T07:32:08.770312Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2017-07-10T07:32:08.770315Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2017-07-10T07:32:08.770318Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2017-07-10T07:32:08.770321Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2017-07-10T07:32:08.770324Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2017-07-10T07:32:08.770327Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2017-07-10T07:32:08.770330Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2017-07-10T07:32:08.770332Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2017-07-10T07:32:08.770335Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2017-07-10T07:32:08.770338Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2017-07-10T07:32:08.770355Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2017-07-10T07:32:08.770359Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2017-07-10T07:32:08.770362Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2017-07-10T07:32:08.770365Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2017-07-10T07:32:08.770368Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2017-07-10T07:32:08.770371Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2017-07-10T07:32:08.770374Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2017-07-10T07:32:08.770377Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2017-07-10T07:32:08.770380Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2017-07-10T07:32:08.770383Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2017-07-10T07:32:08.770386Z 0 [Note] Shutting down plugin 'InnoDB'
2017-07-10T07:32:08.770443Z 0 [Note] InnoDB: FTS optimize thread exiting.
2017-07-10T07:32:08.770499Z 0 [Note] InnoDB: Starting shutdown...
2017-07-10T07:32:08.874289Z 0 [Note] InnoDB: Dumping buffer pool(s) to /usr/local/var/mysql/ib_buffer_pool
2017-07-10T07:32:08.875318Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170710  9:32:08
2017-07-10T07:32:10.223385Z 0 [Note] InnoDB: Shutdown completed; log sequence number 3325689
2017-07-10T07:32:10.224051Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2017-07-10T07:32:10.224066Z 0 [Note] Shutting down plugin 'MEMORY'
2017-07-10T07:32:10.224070Z 0 [Note] Shutting down plugin 'CSV'
2017-07-10T07:32:10.224073Z 0 [Note] Shutting down plugin 'sha256_password'
2017-07-10T07:32:10.224075Z 0 [Note] Shutting down plugin 'mysql_native_password'
2017-07-10T07:32:10.224322Z 0 [Note] Shutting down plugin 'binlog'
2017-07-10T07:32:10.224448Z 0 [Note] mysqld: Shutdown complete

What is wrong?

I have tried reinstalling mysql etc, but same problem every time.

Most helpful comment

Got it working by running

sudo chown -R _mysql:_mysql /usr/local/var/mysql

And then changing from 127.0.0.1 to localhost.

All 2 comments

I have tried changing ports, changing from localhost to 127.0.0.1. Everything. Nothing works.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=abc123abc123

Got it working by running

sudo chown -R _mysql:_mysql /usr/local/var/mysql

And then changing from 127.0.0.1 to localhost.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alshie picture Alshie  路  4Comments

AlexVipond picture AlexVipond  路  4Comments

hsleewis picture hsleewis  路  5Comments

dustinleblanc picture dustinleblanc  路  4Comments

EHLOVader picture EHLOVader  路  4Comments