zsh: command not found: mysql. MySQL is not compatible for zsh? - mysql

Isn't possible to install MySQL in zsh in macOS?
I have been trying to install MySQL on my Mac.
zsh: command not found: mysql
Should I give up setting MySQL on zsh and try to do in bash?
% brew install mysql#5.7
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/manifests/5.7.32-2
Already downloaded: /Users/stackover/Library/Caches/Homebrew/downloads/abe6a0a4787f4c4bd9c6d14e27d98d868c1f0f619cbbba601e8225--mysql#5.7-5.7.32-2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/blobs/sha256:82867504
Already downloaded: /Users/stackover/Library/Caches/Homebrew/downloads/8db250bb2773af3411c71cf86232ed647cdf9366670c716c52574d--mysql#5.7--5.7.32.arm64_big_sur.bottle.2.tar.gz
==> Pouring mysql#5.7--5.7.32.arm64_big_sur.bottle.2.tar.gz
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
mysql#5.7 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have mysql#5.7 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
For compilers to find mysql#5.7 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/mysql#5.7/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql#5.7/include"
To have launchd start mysql#5.7 now and restart at login:
brew services start mysql#5.7
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/mysql#5.7/bin/mysql.server start
==> Summary
🍺 /opt/homebrew/Cellar/mysql#5.7/5.7.32: 319 files, 233.7MB
stackover#stackoverjunoMacBook-Air ~ % echo 'export PATH="/opt/homebrew/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
stackover#stackoverjunoMacBook-Air ~ % myql --version
zsh: command not found: myql
stackover#stackoverjunoMacBook-Air ~ % mysql --version
zsh: command not found: mysql
stackover#stackoverjunoMacBook-Air ~ % export LDFLAGS="-L/opt/homebrew/opt/mysql#5.7/lib"
stackover#stackoverjunoMacBook-Air ~ % export CPPFLAGS="-I/opt/homebrew/opt/mysql#5.7/include"
echo 'export PATH="/opt/homebrew/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/opt/homebrew/opt/mysql#5.7/lib"
I checked if it installed:
stackover#stackoverjunoMacBook-Air ~ % mysql --version
but
zsh: command not found: mysql
I also tried this:
stackover#stackoverjunoMacBook-Air ~ % mysql -uroot
zsh: command not found: mysql

stackover#stackoverjunoMacBook-Air ~ % echo 'export PATH="/opt/homebrew/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
stackover#stackoverjunoMacBook-Air ~ % mysql --version
zsh: command not found: mysql
Your shell does not automagically pick up new executables from your $path. For the shell to find the new executable, you will need to
rebuild your shell’s command lookup table with
hash -fr
restart your shell with
exec zsh
or open a new tab in your terminal.

Related

can not find mysqlbinlog command in docker?

run mysql docker run -d --name=mysql-server -p 3306:3306 -e MYSQL_ROOT_PASSWORD=t123456 mysql:8.0.30
find command: find / -name mysqlbinlog,it only return one line:
sh-4.4# find / -name mysqlbinlog
find: '/proc/1/map_files': Permission denied
and run mysqlbinlog commmand failed:
sh-4.4# mysqlbinlog
sh: mysqlbinlog: command not found
--update--
i change version from 8.0.30 to 8.0.23 according to can't find mysqlbinlog in docker container [mysql/mysql-server:8.0.23] , and the command can be found , why is it missed in newer version?
Available in latest debian version
8.0.30-debian

mysql command is not found in macOS

I have installed MySQL with .dmg installation file according to the official page. But it returns command not found: mysql when I execute mysql command.
How to fix this issue?
The documentation for MySQL says:
When installing using the package installer, the files are installed into a directory within /usr/local matching the name of the installation version and platform. For example, the installer file mysql-5.7.29-osx10.13-x86_64.dmg installs MySQL into /usr/local/mysql-5.7.29-osx10.13-x86_64/.
Once you verify that there is a bin folder in this directory, you have to make sure that the terminal looks for the MySQL command there. This can be done by executing the following command:
export PATH=$PATH:/usr/local/<my-path>/bin
Adding the following line to .bash_profile worked for me:
export PATH=${PATH}:/usr/local/mysql/bin/
Then either restart the terminal or to apply the changes to an existing session, run:
source ~/.bash_profile
If you had installed mysql#5.7 using brew:
paste/type below command in terminal:
echo 'export PATH="/usr/local/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
then paste/type:
mysql -u root
boom!!!!
reason: brew files are installed in usr/local/opt
Try this if you have not upgraded your OS and wants to access mysql
instead of -> mysql -u root -p
use -> /usr/local/mysql/bin/mysql -u root -p

mac mysql fail to help add an environment variable

Terminal:
mysql -uroot -p
zsh: command not found: mysql
➜ ~ echo $PATH
/Users/zhangzhenxing/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:B:A:/sbin:/usr/local/git/bin
➜ ~ export PATH=$PATH:/usr/local/bin:/usr/local/mysql/bin
➜ ~ echo $PATH
/Users/zhangzhenxing/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:B:A:/sbin:/usr/local/git/bin:/usr/local/bin:/usr/local/mysql/bin
➜ ~ mysql -uroot -p
Enter password:
Execution of export PATH = $ PATH: / usr / local / bin: / usr / local / mysql / bin, after restarting the terminal, mysql still can not start, the reason I ask that God horse,
You need to re-execute the source order?
Try: echo "export PATH=\$PATH:/usr/local/bin:/usr/local/mysql/bin" >> ~/.zshrc, then restart your terminal.
If I understand your question correctly, you are trying to set the PATH environment variable when a new shell is started. This is typically done by editing your ~/.zshrc file.

Getting MySQL installed

I have downloaded mysql-5.6.17-osx10.7-x86.tar.gz from here. Now I've got a folder full of MySQL-related files. Trouble is, I don't know what to do to install MySQL. I tried executing mysql_install_db, but the result was:
Last login: Sat May 24 10:45:08 on ttys000
host237-40-dynamic:~ michelegorini$ /Users/michelegorini/Downloads/mysql-5.6.17-osx10.7-x86/scripts/mysql_install_db ; exit;
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
logout
[Process completed]
So what do I do now?
Update:
Taking the answer into account, I tried something, with this result:
Last login: Sat May 24 10:45:08 on ttys000
host237-40-dynamic:Hakka_ michelegorini$ $ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
curl: (22) The requested URL returned error: 400
-bash: $: command not found
host237-40-dynamic:Hakka_ michelegorini$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" && brew install git &&
> brew update
curl: (22) The requested URL returned error: 400
-bash: brew: command not found
host237-40-dynamic:Hakka_ michelegorini$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" && brew install git && brew update && brew install mysql
curl: (22) The requested URL returned error: 400
-bash: brew: command not found
host237-40-dynamic:Hakka_ michelegorini$
What now?
The homebrew package manager takes away the pain in installing packages on your computer.
Here's how to install mysql on a mac
The command in one line:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" && brew install git && brew update && brew install mysql

MySQL Start Error

I am trying to install MySQL 5.6.17 on Ubuntu Linux and I am having difficulties doing so. I opened the MySQL Reference and opened "Installing MySQL on Unix/Linux Using Generic Binaries". I followed the following step:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
//Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
After that when I try to start MySQL using /etc/init.d/mysql.server start I get the following error:
Couldn't find MySQL server (/usr/bin/mysqld_safe)
I looked in /usr/bin and I found mysqld_safe. Any suggestions on how to fix that problem. Please reply with a detailed solution.
Thank You
It seems you have installed Mysql in "/usr/local" and init script is looking for binaries in "/usr"
Change the "basedir" in /etc/init.d/mysql.server to :
basedir=/usr/local
The fact that you found /usr/bin/mysqld_safe suggests that MySQL in some shape or form was preinstalled on your OS. This can cause some confusion, in particular due to location of config files.
So for instance, on some versions of Ubuntu, the packages mysql-common is pre-installed, which means you might have an /etc/mysql/my.conf file with some defaults in it. When you install from the tar file to /usr/local, follow the INSTALL-BINARIES (or equivalent) instructions, and try to start /etc/init.d/mysql.server start you might get errors as the one you report ("Couldn't find MySQL server (/usr/bin/mysqld_safe)"), because the default configuration in /etc/init.d/mysql.server and any /etc/my.cnf that you created (optional step during install) is getting over-ridden by a setting in the OS installed /etc/mysql/my.conf. Note that this might happen even if you change the values in /etc/init.d/mysql.server and/or /etc/my.cnf.
One way out is to merge /etc/my.cnf and /etc/mysql/my.cnf into a single file at one of these locations, with the correct defaults that you wish to use.