0

I installed MySQL 8.0 using brew install mysql.

When I run mysql -V I get 8.0.32.

When I login to the CLI by doing mysql -u root instead I see Server version: 5.7.40 Homebrew.

If I connect with an SQL client and run SHOW VARIABLES WHERE Variable_name = 'basedir'; then I get /usr/local/Cellar/mysql@5.7/5.7.40/.

The dir /usr/local/Cellar/mysql@5.7 does not exist on my computer. Only the dir /usr/local/Cellar/mysql/8.0.32.

If I explicitly do /usr/local/Cellar/mysql/8.0.32/bin/mysql -u root then I still get Server version: 5.7.40 Homebrew.

When I run queries with syntax supported by 8.0, they don't work, implying that even tho Homebrew says it install 8.0, it actually installed 5.7.

I tried reinstalling mysql, but same issue.

What is going on here?

eComEvo
  • 11,669
  • 26
  • 89
  • 145
  • mysql -V is showing you the version of the mysql command line client you are running, which has nothing to do with the server version. the server may not even be running on your computer (though it probably is) – ysth Apr 12 '23 at 02:07
  • This is a localhost installation, so it is definitely running on my computer, which is why the basedir output of the query shows `/usr/local/Cellar/mysql@5.7/5.7.40/`. – eComEvo Apr 12 '23 at 03:02
  • Yes, clearly the client and the server are different versions. The server is what parses and executes queries, so you're limited to features supported by MySQL 5.7. – Bill Karwin Apr 12 '23 at 04:26
  • So the obvious question I have is why is the server in the `8.0.32` dir version `5.7.40` that it is referencing? – eComEvo Apr 12 '23 at 16:45
  • It could be that you're connected to a remote server even though you don't think you are. Run the `status` command in the mysql client. – Bill Karwin Apr 12 '23 at 16:52
  • 1
    Another possibility is that you still have a MySQL 5.7 process running, even though all its files have been unlinked. As long as that process still has an open file handle, the files still exist, even though you can't see them with `ls`. Try `ps -ef | grep mysql` to see which mysqld is running. – Bill Karwin Apr 12 '23 at 16:56
  • It's definitely local `Connection: Localhost via UNIX socket` and `Server version: 5.7.40 Homebrew`. Your second hunch is correct about another process as I get `/usr/local/opt/mysql@5.7/bin/mysqld --basedir=/usr/local/opt/mysql@5.7` so it looks like there is a legacy copy probably installed with Mac OS interfering. I'm going to try stripping all semblance of MySQL according to this post and then reinstall: https://stackoverflow.com/questions/4359131/brew-install-mysql-on-macos – eComEvo Apr 12 '23 at 17:01
  • That was the solution. – eComEvo Apr 14 '23 at 20:14

0 Answers0