Find Out Where MySQL Is Installed on MAC Os X

Find out where MySQL is installed on Mac OS X

To check MySQL version of MAMP , use the following command in Terminal:

/Applications/MAMP/Library/bin/mysql --version

Assume you have started MAMP .

Example output:

./mysql  Ver 14.14 Distrib 5.1.44, for apple-darwin8.11.1 (i386) using  EditLine wrapper

UPDATE: Moreover, if you want to find where does mysql installed in system, use the following command:

type -a mysql

type -a is an equivalent of tclsh built-in command where in OS X bash shell. If MySQL is found, it will show :

mysql is /usr/bin/mysql

If not found, it will show:

-bash: type: mysql: not found

By default , MySQL is not installed in Mac OS X.

Sidenote: For XAMPP, the command should be:

/Applications/XAMPP/xamppfiles/bin/mysql --version

Where is MYSQL installed on Mac?

The installation layout is similar to that of a tar file binary
distribution; all MySQL binaries are located in the directory
/usr/local/mysql/bin. The MySQL socket file is created as
/tmp/mysql.sock by default. See Section 2.7, “Installation Layouts”.

From: http://dev.mysql.com/doc/refman/5.0/en/macosx-installation.html

It's probably not added to your $PATH, thus why the commands aren't visible in the terminal. Try typing echo $PATH on your terminal to see if /usr/local/mysql/bin is included in the path.

Additionally, on the terminal, you can type which mysql. If that returns nothing your environment is not finding your MySQL binary.

Can't find MySQL on MAC

Terminal window:

cd /usr

To view hidden folders in Finder:

  1. Open Terminal found in Finder > Applications > Utilities
  2. In Terminal, paste the following:

    defaults write com.apple.finder AppleShowAllFiles YES

  3. Press return.

  4. Hold the Option/alt key,
  5. Then right click on the Finder icon in the dock and select Relaunch

MySQL data directory location

See if you have a file located under /etc/my.cnf. If so, it should tell you where the data directory is.

For example:

[mysqld]
set-variable=local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
...

My guess is that your mysql might be installed to /usr/local/mysql-XXX.

You may find these MySQL reference manual links useful:

  • Installing MySQL 8.0 on MacOS
  • Installing MySQL 5.7 on MacOS
  • Installing MySQL 5.6 on MacOS
  • Installing MySQL 5.5 on MacOS

mysql command is not found in macOS

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

Location of my.cnf file on macOS

This thread on the MySQL forum says:

By default, the OS X installation does not use a my.cnf, and MySQL just uses the default values. To set up your own my.cnf, you could just create a file straight in /etc.

OS X provides example configuration files at /usr/local/mysql/support-files/.

And if you can't find them there, MySQLWorkbench can create them for you by:

  1. Opening a connection
  2. Selecting the 'Options File' under 'INSTANCE' in the menu.
  3. MySQLWorkbench will search for my.cnf and if it can't find it, it'll create it for you

Where is the created MySQL database folder stored in Mac OS X?

Run this query:

SELECT @@datadir, @@innodb_data_home_dir

The exact files and or subfolders depend on the exact database name and table types.

Mac install and open mysql using terminal

(Updated for 2017)

When you installed MySQL it generated a password for the root user. You can connect using

/usr/local/mysql/bin/mysql -u root -p

and type in the generated password.

Previously, the root user in MySQL used to not have a password and could only connect from localhost. So you would connect using

/usr/local/mysql/bin/mysql -u root

Mysql command not found in OS X 10.7

This is the problem with your $PATH:

/usr/local//usr/local/mysql/bin/private/var/mysql/private/var/mysql/bin.

$PATH is where the shell searches for command files. Folders to search in need to be separated with a colon. And so you want /usr/local/mysql/bin/ in your path but instead it searches in /usr/local//usr/local/mysql/bin/private/var/mysql/private/var/mysql/bin, which probably doesn't exist.

Instead you want ${PATH}:/usr/local/mysql/bin.

So do export PATH=${PATH}:/usr/local/mysql/bin.

If you want this to be run every time you open terminal put it in the file .bash_profile, which is run when Terminal opens.



Related Topics



Leave a reply



Submit