zsh: command not found: mysql - mysql

using monteray 12.6
putting
mysql --version
into the terminal gives me
zsh: command not found: mysql
but if i do
/usr/local/mysql/bin/mysql --version
i get
/usr/local/mysql/bin/mysql Ver 8.0.31 for macos12 on x86_64 (MySQL Community Server - GPL)
which works
folder paths
https://imgur.com/a/Zw0E3Hv
my .bash_profile
https://imgur.com/a/Zw0E3Hv
export PATH="${PATH}:/usr/local/mysql/bin/"
.zshrc
https://imgur.com/a/7qtR7Om

put
export PATH=/usr/local/mysql-8.0.31-macos12-x86_64/bin:$PATH
in .zshrc file
thanks to user
user1934428
for taking the time to reply to me

Related

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

How do I install command line MySQL client on mac?

I want to install the MySQL client for the command line, not a GUI. I have searched over the web but only found instructions on installing the MySQL server.
install MySQLWorkbench, then
export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
This strictly installs a command line client, without the other overhead:
Install Homebrew (if you don't have it):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then, install mysql-client:
brew install mysql-client
Then, add the mysql-client binary directory to your PATH:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
Finally, reload your bash profile:
source ~/.bash_profile
Then you should be able to run mysql in a terminal, if not try opening a new terminal
If you have already installed MySQL from the disk image (dmg) from http://dev.mysql.com/downloads/), open a terminal, run:
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
then, reload .bash_profile by running following command:
. ~/.bash_profile
You can now use mysql to connect to any mysql server:
mysql -h xxx.xxx.xxx.xxx -u username -p
Credit & Reference: http://www.gigoblog.com/2011/03/13/add-mysql-to-terminal-shell-in-mac-os-x/
Best option is:
brew install mysql
Mysql has a client-only set of utilities:
Mysql client shell
https://dev.mysql.com/downloads/shell/
Other command line utilities
https://dev.mysql.com/downloads/utilities/
Mac OSX version available.
There is now a mysql-client formula.
brew install mysql-client
For installing mysql-shell with homebrew, run
brew cask install mysql-shell
you can then launch the mysql shell with
mysqlsh
if you want to enter SQL mode directly, run
mysqlsh --sql
Open the "MySQL Workbench" DMG file and
# Adjust the path to the version of MySQL Workbench you downloaded
cp "/Volumes/MySQL Workbench 6.3.9.CE/MySQLWorkbench.app/Contents/MacOS/mysql" /usr/local/bin
# Make sure it's executable
chmod +x /usr/local/bin/mysql
Eject the DMG disk
Installation command from brew:
$ brew cask install mysql-shell
Look at what you can do:
$ mysqlsh --help
Run query from mysqlsh client installed:
$ mysqlsh --host=192.x.x.x --port=3306 --user=user --password=xxxxx
MySQL Shell 8.0.18
Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
WARNING: Using a password on the command line interface can be insecure.
Creating a session to 'user#192.x.x.x:3306'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 16
Server version: 8.0.18 MySQL Community Server - GPL
No default schema selected;
type \use <schema> to set one.
MySQL 192.x.x.x:3306 ssl JS >
MySQL 192.x.x.x:3306 ssl JS > `\use rafdb`
Default schema set to `rafdb`.
If you installed from the DMG on a mac, it created a mysql client but did not put it in your user path.
Add this to your .bash_profile:
export PATH="/usr/local/mysql/bin:$PATH
This will let you run mysql from anywhere as you.
As stated by the earlier answer you can get both mysql server and client libs by running
brew install mysql.
There is also client only installation. To install only client libraries run
brew install mysql-connector-c
In order to run these commands, you need homebrew package manager in your mac. You can install it by running
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Using MacPorts you can install the client with:
sudo port install mysql57
You also need to select the installed version as your mysql
sudo port select mysql mysql57
The server is only installed if you append -server to the package name (e.g. mysql57-server)
The easiest way would be to install mysql server or workbench, copy the mysql client somewhere, update your path settings and then delete whatever you installed to get the executable in the first place.
The mysql client is available in macOS ports. If you don't have this excellent third party package manager already installed, it is available from here: https://www.macports.org/
Once you have installed macports, open a terminal and make sure everything is up to date:
sudo port selfupdate
There are multiple different versions of MySQL and mariadb (community fork of MySQL) available in the ports repos. List available versions using the following command:
port search 'mariadb*'
I recommend choosing mariadb over mysql as it is, mostly, a drop in replacement (https://mariadb.com/kb/en/mariadb-vs-mysql-compatibility/) and has excellent community support.
If applicable, choose which version of mariadb you want (a list of versions of mariadb is available here: https://downloads.mariadb.org/mariadb/+releases/). If you're not bothered, install the default version:
sudo port install mariadb
Mariadb (including the mysql-compatible command line client) is now available on your system. On my system, the CLI client resides in the following location:
$ /opt/local/bin/mysql --version
/opt/local/bin/mysql Ver 15.1 Distrib 5.5.68-MariaDB, for osx10.15 (x86_64) using readline 5.1
It's obviously a bit inconvenient to type out the full path, /opt/local/bin/mysql each time you want to use the client. Ports has already thought of this problem. To view available versions of mysql on your system, run:
$ port select mysql
Available versions for mysql:
mariadb (active)
none
Choose one from the list. For example, to use mariadb as the default mysql client:
sudo port select mysql mariadb
Now open a fresh terminal window and you should be able to start the mariadb mysql CLI client:
mysql -h <hostname> -u <username> -p
if you need a lighter solution i recommend mysql-shell, install using the command below.
brew cask install mysql-shell
To start after installation type mysqlsh.

mysql.server start not working on mac

I have installed mysql and I get the version of mysql from command prompt by
mysql --version.
But when I try to start / stop my server from command prompt by
mysql.server start
I get an error
-bash: mysql.server: command not found
Have edited my .bash_profile
export PATH=$PATH:/usr/local/mysql/bin/
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
Use this command: sudo /usr/local/mysql/bin/mysqld_safe&

mysqli extension is missing debian

i m try to install mysql-sever on debian (WD mycloud live)
i have tried everything i found on google but no success
/etc/php5/conf.d/mysqli.ini Dont exists
for install i used apt-get -f mysql-server mysql-client mysql-common
so far i have
mysql running
PHP Version 5.4.11-1
Linux WDMyCloud 3.2.26 #1 SMP Fri Dec 27 13:50:41 PST 2013 armv7l
Additional .ini files parsed
/etc/php5/apache2/conf.d/10-pdo.ini,
/etc/php5/apache2/conf.d/20-apc.ini,
/etc/php5/apache2/conf.d/20-curl.ini,
/etc/php5/apache2/conf.d/20-pdo_sqlite.ini,
/etc/php5/apache2/conf.d/20-sqlite3.ini,
/etc/php5/apache2/conf.d/include_path.ini
mysql -- version -> mysql ver 14.14 distrib 5.5.35, for debian-linux-gnu (armv71) using readline 6.2
i installed webmin there i can see my mysql-server information, i have there
Path to mysqlshow command - /usr/bin/mysqlshow
Path to mysqladmin command - /usr/bin/mysqladmin
Path to mysql command - /usr/bin/mysql
Path to mysqldump command - /usr/bin/mysqldump
Path to mysqlimport command - /usr/bin/mysqlimport
MySQL configuration file - /etc/mysql/my.cnf
Mysql Unix socket - /var/run/mysqld/mysqld.sock
Database files directory - /var/lib/mysql
sudo apt-get install php5-mysql
Will install package containing both old one and the new one, so afterwards all you need to do is to add
extension=mysqli.so
in your php.ini, restart apache and it should work.
Source:
https://stackoverflow.com/a/10835420/3566788
I encountered above issue while configuring 'phpmyadmin' for php5.7 and mysql#5 combination that was required for one of my old raspberry pi projects.
In my case when I tried the
sudo apt-get install php5-mysql
I got error -
E: Package 'php5-mysqli' has no installation candidate
The error also mentioned about the replacement packages,
Package php5-mysqli is not available, but is referred to by another
package. This may mean that the package is missing, has been
obsoleted, or is only available from another source However the
following packages replace it: php5-mysqlnd php5-mysql
I executed following and it worked for me.
sudo apt install php5-mysqlnd
Hope it helps.

MySQL starting error on CentOS 6

I have removed the preinstalled MySQL from CentOS 6 using the command-
yum remove mysql mysql-*
Now, I want to install "MySQl-server-5.5.28-1.linux2.6.i386.rpm" in my system.
But it could not start on my system. Please tell me how to start the MySQL with user account as well as in root also.
I have done this:-
[rex#dhcppc0 MySQL]$
[rex#dhcppc0 MySQL]$ su -
Password:
[root#dhcppc0 ~]# cd /home/rex/Documents/Software/MySQL
[root#dhcppc0 MySQL]# rpm -i MySQL-server-5.5.28-1.linux2.6.i386.rpm
package MySQL-server-5.5.28-1.linux2.6.i386 is already installed
[root#dhcppc0 MySQL]# mysql -u
-bash: mysql: command not found
[root#dhcppc0 MySQL]# mysql -u mysql
-bash: mysql: command not found
[root#dhcppc0 MySQL]# mysql.server start
-bash: mysql.server: command not found
MySQL-server-xxxx is package that contains only MySQL Server. Executable file for server is "mysqld" - "d" letter is for a daemon).
File that you trying to execute (mysql) is MySQL client. There is no client application in server package.
Please install MySQL-client-xxxx package, where xxxx is a version.
Execute the initscript below as a root user:
# /etc/init.d/mysql start
If you try to access the database from local client, you need to install MySQL-client-5.5.28-1.linux2.6.i686.rpm package.
Then you can control the MySQL database.
$ /usr/bin/mysql -u mysql