1
zsh: command not found: mysql

I have exhausted the forums that provide suggestions and nothing is working and most talk about bash_profile, but this is an issue in my zsh environment.

It seems like it is definitely a path problem, this is what mines looks like:

ldco2016@DCortes-MacBook-Pro-3 ~/Projects/photogallery $ echo $PATH                                                                                                                                   [ruby-2.2.1]
/usr/local/share/npm/bin:/Users/ldco2016/.nvm/versions/node/v6.9.1/bin:/Users/ldco2016/.rvm/gems/ruby-2.2.1/bin:/Users/ldco2016/.rvm/gems/ruby-2.2.1@global/bin:/Users/ldco2016/.rvm/rubies/ruby-2.2.1/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/usr/local/mysql/bin:/Users/ldco2016/.rvm/bin:/Users/ldco2016/.rvm/bin:/usr/local/share/npm/bin:/Users/ldco2016/.composer/vendor/bin:/usr/local/mysql/bin:/usr/local/:/usr/local/mysql/bin

Also, when I go to /usr/local, there is no mysql folder in that directory:

ldco2016@DCortes-MacBook-Pro-3 /usr/local $ ll                                                                                                                                                        [ruby-2.2.1]
total 0
drwxr-xr-x    4 ldco2016  admin   136B Oct 13 14:01 Caskroom
drwxr-xr-x   96 ldco2016  admin   3.2K Nov 25 18:13 Cellar
drwxr-xr-x    3 ldco2016  admin   102B Aug  6 17:06 Frameworks
drwxr-xr-x   16 ldco2016  admin   544B Nov 25 18:12 Homebrew
drwxr-xr-x    6 root      wheel   204B Jun 28 08:18 MacGPG2
drwxr-xr-x@  11 ldco2016  staff   374B Aug  2 18:26 apache-maven
drwxrwxr-x  432 ldco2016  admin    14K Nov 25 18:13 bin
drwxr-xr-x   16 ldco2016  admin   544B Nov 25 18:13 etc
drwxr-xr-x   20 root      wheel   680B Oct 19 13:12 go
drwxr-xr-x  122 ldco2016  admin   4.1K Oct 26 20:11 include
drwxr-xr-x  282 ldco2016  admin   9.4K Oct 23 04:36 lib
drwxr-xr-x   96 ldco2016  admin   3.2K Nov 25 18:13 opt
drwxr-xr-x    4 ldco2016  admin   136B Oct  3 14:15 sbin
drwxr-xr-x   55 ldco2016  admin   1.8K Oct 26 20:11 share
drwx------@  46 ldco2016  staff   1.5K Aug  1 17:48 terraform
drwxr-xr-x   10 ldco2016  admin   340B Sep 21 18:01 var

These are the places where I have found mysql:

/Applications/MAMP/db/mysql
/Applications/MAMP/db/mysql/mysql
/Applications/MAMP/Library/bin/mysql
/Applications/MAMP/Library/lib/perl5/site_perl/5.22.0/darwin-2level/auto/DBD/mysql
/Applications/MAMP/Library/lib/perl5/site_perl/5.22.0/darwin-2level/DBD/mysql
/Applications/MAMP/Library/lib/python2.7/site-packages/mysql
/Applications/MAMP/tmp/mysql
/Applications/Zend Studio.app/Contents/Eclipse/plugins/com.zend.php.datatools.core_13.5.1.v20160705-1334/resources/drivers/mysql
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Library/Application Support/appsolute/MAMP PRO/db/mysql
/Library/Application Support/appsolute/MAMP PRO/db/mysql/mysql
/private/etc/paths.d/mysql
/private/var/mysql
/Users/ldco2016/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0/lib/active_record/connection_adapters/mysql
/Users/ldco2016/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql
/Users/ldco2016/.rvm/gems/ruby-2.3.1@rails5.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/mysql
/Users/ldco2016/Documents/PycharmProjects/Survey/env/lib/python3.5/site-packages/django/contrib/gis/db/backends/mysql
/Users/ldco2016/Documents/PycharmProjects/Survey/env/lib/python3.5/site-packages/django/db/backends/mysql
/Users/ldco2016/ps-ansible/roles/mysql
/Users/ldco2016/workspace/todo/rails/activerecord/lib/active_record/connection_adapters/mysql
/usr/local/Cellar/ansible/2.1.1.0/libexec/lib/python2.7/site-packages/ansible/modules/core/database/mysql
/usr/local/Cellar/ansible/2.1.1.0/libexec/lib/python2.7/site-packages/ansible/modules/extras/database/mysql
/usr/local/lib/python2.7/site-packages/ansible/modules/core/database/mysql
/usr/local/lib/python2.7/site-packages/ansible/modules/extras/database/mysql
/usr/local/lib/python3.5/site-packages/django/contrib/gis/db/backends/mysql
/usr/local/lib/python3.5/site-packages/django/db/backends/mysql
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0/lib/active_record/connection_adapters/mysql

How can I proceed based on this evidence?

halfer
  • 19,824
  • 17
  • 99
  • 186
Daniel
  • 14,004
  • 16
  • 96
  • 156
  • Windows? Linux? Give us a bit of a clue – RiggsFolly Dec 20 '16 at 16:22
  • Sounds like you don't have mysql installed at all. – aynber Dec 20 '16 at 16:25
  • Set your env variable for zsh. I mean set your mySQL path to be recognized by zsh environment. There are lots of tutorial on how to check and add env variables in zsh. – BetaDev Dec 20 '16 at 16:30
  • @RiggsFolly, I am doing this on a Mac. – Daniel Dec 20 '16 at 16:36
  • @aynber, how do I install mysql in the context of working with my Laravel app? I believe I have already added env variables in zsh. – Daniel Dec 20 '16 at 16:39
  • If mysql is found in /usr/local/mysql/bin/mysql, you just need to add it to the path. (http://stackoverflow.com/questions/8195418/cant-access-mysql-from-command-line-mac , http://stackoverflow.com/questions/10577374/mysql-command-not-found-in-os-x-10-7). If it's not in /usr/local at all, then you need to [install the application itself](https://dev.mysql.com/doc/refman/5.6/en/osx-installation-pkg.html). – aynber Dec 20 '16 at 16:48
  • @aynber, thank you, I went ahead and installed it because apparently I did not have it. Now when I do a mysql -u root, I get this error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2), so I see this as progress. – Daniel Dec 20 '16 at 17:07
  • Now that it's install, it probably needs to be started. Check your MAMP configuration, there should be an option to start it there. – aynber Dec 20 '16 at 17:20
  • @aynber, I installed it through homebrew and started the service via homebrew, but now when I tried php artisan migrate, I get this error: [Illuminate\Database\QueryException] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations) [PDOException] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) – Daniel Dec 20 '16 at 17:23
  • Sounds like it's the incorrect password for root. You can try to reset it or make sure it's correct in your .env file. – aynber Dec 20 '16 at 17:27
  • @aynber, when I hit php artisan migrate, I got a migration table created successfully, although those tables came with the installation of Laravel and were not created by me. – Daniel Dec 20 '16 at 18:00
  • @aynber go ahead and post your answer as the correct one. – Daniel Dec 20 '16 at 18:54

1 Answers1

0

In order to use mysql, you first need to install the server itself, then add it to the PATH. Once it's installed and running, make sure that the correct credentials are in your .env file.

aynber
  • 22,380
  • 8
  • 50
  • 63