macos-sonomamysql-cli

MySQL is not working on MacOS 14 (Sonoma) from command line


I have tried to install MySQL. I downloaded the community Edition of MySQL 8.2 from https://dev.mysql.com/downloads/mysql/ and installed it. The Installation process went on smoothly but when I tried to connect to mySQL Server from command line using command mysql -u root -p I got following error zsh: command not found: mysql I also tried to run where is and which command the response is as follows focus@MacBook-Pro bin % which mysqld mysqld not found focus@MacBook-Pro bin % whereis mysql mysql: focus@MacBook-Pro bin % whereis mysq mysq: focus@MacBook-Pro bin % whereis mysqld mysqld: focus@MacBook-Pro bin % whichis mysql mysql not found

I checked my MySQL Installation (Screenshot below) MySQL Service is runnign

I found some blogs that says that error may be due to path settings. I even tried to run the command from /usr/local/mysql/bin still no luck


Solution

  • Since your MySQL Server is online you can try connecting with MySQL Workbeanch still if you want to use terminal and connect to MySQL on command line you will need to add the path of your MySQL Binaries which is located in /usr/local/mysql/bin to your system path run following commands on terminal

    echo "export PATH=/usr/local/mysql/bin:$PATH" >> ~/.zshrc
    source ~/.zshrc
    

    Now you can use terminal to connect to MySQL Server

    mysql -u root -p