Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

121 Views Asked by At

While installing a new ruby version through RVM my mysql got updated from 5.7 to 5.8. My application is not supports 5.8 and hence trying to downgrade mysql version back to 5.7.

But couldn't do it successfully.

# Stopped currently running mysql
brew services stop mysql

# uninstall mysql
brew uninstall mysql

# removed old config files
sudo rm -rf /opt/homebrew/var/mysql

# install required version
# brew install [email protected]

But I can see a warning message as well post-install step did not complete successfully

2023-09-14T13:53:56.278342Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-09-14T13:53:56.281246Z 0 [Warning] Setting lower_case_table_names=2 because file system for /opt/homebrew/var/mysql/ is case insensitive
2023-09-14T13:53:56.351496Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-09-14T13:53:56.366220Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-09-14T13:53:56.423706Z 0 [ERROR] unknown variable 'mysqlx-bind-address=127.0.0.1'
2023-09-14T13:53:56.423724Z 0 [ERROR] Aborting

Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall [email protected]

I tried running brew postinstall [email protected] But same error returned

==> Postinstalling [email protected]
==> /opt/homebrew/Cellar/[email protected]/5.7.43/bin/mysqld --initialize-insecure --user=mike --basedir=/opt/homebrew/Cellar/[email protected]/5.7.43 --datadir=/opt/homebrew/var/mysql --tmpdir=/tmp
Last 15 lines from /Users/mike/Library/Logs/Homebrew/[email protected]/post_install.01.mysqld:
2023-09-14 19:32:32 +0530

/opt/homebrew/Cellar/[email protected]/5.7.43/bin/mysqld
--initialize-insecure
--user=mike
--basedir=/opt/homebrew/Cellar/[email protected]/5.7.43
--datadir=/opt/homebrew/var/mysql
--tmpdir=/tmp

2023-09-14T14:02:32.051634Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-09-14T14:02:32.052340Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2023-09-14T14:02:32.052351Z 0 [ERROR] Aborting

Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall [email protected]

But I can see correct version of mysql is installed

mysql -V
mysql  Ver 14.14 Distrib 5.7.43, for osx10.17 (x86_64) using  EditLine wrapper

I can even start mysql service

But when I try to do mysql_secure_installation It won't allow me to setup password for root user.

mysql_secure_installation


Securing the MySQL server deployment.

Enter password for user root:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I tried multiple solutions and re-iterated the same flow. But still stuck at the same place

0

There are 0 best solutions below