I just installed MySQL on my Mac and I can't find usr/local/mysql on my machine. I cd to the home directory but when I type in cd usr I can't see it and I am unable to determine if MySQL was installed.
How can I find the installation?
Terminal window:
cd /usr
To view hidden folders in Finder:
Open Terminal found in Finder > Applications > Utilities
In Terminal, paste the following:
defaults write com.apple.finder AppleShowAllFiles YES
Press return.
Hold the Option/alt key,
Then right click on the Finder icon in the dock and select Relaunch
go to terminal
type cd /usr/local
you will find your mysql folder
Related
I am not sure if this is different on earlier OS X but I would like to share how I got the MySQL Preference Pane to work with MariaDB 10.10 installed with homebrew.
First an excellent guide to creating a startup script on OS X:
How do I start MariaDB on boot on Mac OS X?
MySQL has a preference pane so you can start/stop MariaDB from System Settings. I installed the MySQL Preference Pane.
But it does not work on a brew install mariadb since the paths are different.
Download and install the MySQL Preference Pane (included in MySQL Mac OS X dmg file download). Open the preference pane and you will see it complains about missing path etc. Does not work.
If this dir does not exist, create it
mkdir /usr/local/mysql
Create a symblink to share in this dir.
cd /usr/local/mysql
ln -s /usr/local/Cellar/mariadb/10.0.15/share share
Make a symblink to bin in this dir.
ln -s /usr/local/Cellar/mariadb/10.0.15/bin bin
The paths may be different if you have another married version. I have installed 10.0.5.
Data is located in "/usr/local/var/mysql". I did not add any symblink to the data dir. Seems it works fine. I guess this is standard location and no need to specify it.
Here is how I solved this:
Download and install the MySQL Preference Pane (included in MySQL Mac OS X dmg file download). Open the preference pane and you will see it complains about missing path etc. Does not work.
If this dir does not exist, create it
mkdir /usr/local/mysql
Create a symblink to share in this dir.
cd /usr/local/mysql
ln -s /usr/local/Cellar/mariadb/10.0.15/share share
Make a symblink to bin in this dir.
ln -s /usr/local/Cellar/mariadb/10.0.15/bin bin
The paths may be different if you have another mariaDB version. I have installed 10.0.15.
Data is located in "/usr/local/var/mysql". I did not add any symblink to the data dir. Seems it works fine. I guess this is standard location and no need to specify it.
I am new to the database world and I ran into some problems....
My hard disk on my Mac says I have less than 8gb left of free space. For this reason, I would like to move my MySQL data directory to an external network drive called ls-xld4c.
I have been trying to follow the rules to do so via http://mailsteward.com/nickstek/?p=22
As noted from step 3 from the link above:
I copied the /usr/local/mysql/data directory and all of its files and subdirectories to the
new location at /Volumes/share/MYSQL
So here is what i typed in my terminal:
cd /Volumes/share/MYSQL
cp -R /usr/local/mysql/data
which returns the following: ( i do not know what this means)
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
Here is some info that might be handy:
1) Server version: 5.6.17 MySQL Community Server (GPL)
2) Where my external drive is located: /Volumes/share
-The network drive is called ls-xld4c and is 1TB in size(I don't know if that is relevant)
The specific folder I want to put the directory reads that it is found in...
Server : smb://ls-xld4c/share/MYSQL , however /Volumes/share/MYSQL shows that it is a valid directory
3) I do not have a password and the user is root
You have almost done it. The error is flagged because you have not specified the destination directory which should be your current working directory. Please use CO command as:
cp -R /usr/local/mysql/data .
The ending dot means current directory which you have already set by using:
cd /Volumes/share/MYSQL
By the way, the following steps are required:
Stop MySQL service.
Copy data files from the directory as specified in "my.cnf" or "my.inf" (in case of windows).
Paste data to destination dir.
Change "my.cnf" or "my.inf" such as the "datadir" entry specifies the destination path.
Restart MySQL.
1. Stop MySQL
sudo /etc/init.d/mysql stop
2. Change Data Directory
sudo cp -R -p /var/lib/mysql /newlocation
3. Edit MySQL default configuration file
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
change 'datadir' to /newlocation
sudo vim /etc/apparmor.d/usr.sbin.mysqld
change '/var/lib/mysql' two-entries to /newlocation
4. Start MySQL
sudo /etc/init.d/mysql restart
On macOS Big Sur, MySQL installer used to install MySQL:
Go to System Preferences > MySQL > click on Stop MySQL Server
In configuration tab, you can see current Data Directory
Copy data folder to your destination directory
Change "Data Directory" address to your destination address > then Apply
Go to System Preferences > Security & Privacy > Privacy > Full Disk Access and make sure "mysqld" is checked here
Go to System Preferences > MySQL > click on Start MySQL Server
if you do not do step 5, the service won't start back.
hope it helps for those with permission issues
I recently upgraded my Mac to Mavericks and am having trouble getting MySQL to work.
I removed my previous MySQL installation per instructions found on the web, then downloaded the DMG file and ran the installer - after which, I was able to get it running, but was not able to log in.
I noticed the installer created a /usr/local/mysql/ directory which points to /usr/local/mysql-5.6.19-osx10.7-x86_64
I then replaced the /usr/local/mysql-5.6.19-osx10.7-x86_64/data directory with the old data directory, and now I can't start MySQL.
I get the error: "warning the /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user" and can no longer start MySQL.
I tried to change permissions of the directory with the following without luck:
sudo chmod -R 777 /usr/local/mysql/
sudo chmod -R 777 /usr/local/mysql-5.6.19-osx10.7-x86_64
sudo chown -R mysql:mysql /usr/local/mysql/data
sudo chown -R mysql:mysql /usr/local/mysql/data
sudo chown -R _mysql /usr/local/var/mysql
chown: /usr/local/var/mysql: No such file or directory
sudo chmod -R o+rwx /usr/local/var/mysql
chmod: /usr/local/var/mysql: No such file or directory
I did modify the plist file and cnf files as described here:
https://community.jboss.org/blogs/tedjones/2014/05/02/getting-mysql-up-and-running-after-upgrading-to-mavericks?_sscc=t
Not sure what else to do.
I was able to solve this problem. You just have to be meticulous when you run the install.
Please note that upgrading from Mac OS 10.8 or older to Mavericks will cause MySQL to no longer run (in other words, "Are you sure you want to upgrade to Mavericks?")
With MySQL non-functional, I decided to reinstall MySQL and upgrade to the newest version.
I followed the instructions in the link above with the following words of advice:
Backup your MySQL data directory before doing anything.
The MySQL data file is located in the /usr/local/mysql-5.6.19-osx10.7-x86_64/data directory (or similar, depending on what version you have installed).
BACK IT UP!
Make sure you stop MySQL before installing the upgraded version.
If your plist file has keepalive set to True, every time you try to quit MySQL, it will quit (or will appear to quit) but then immediately restart.
If you want to use the Preference Pane to start and stop MySQL, make sure you set keepalive in the .plist file to false, otherwise the Preference Pane won't work.
I tried to kill the plist process after making the change, but it wouldn't work. I just restarted my Mac and from that point on, I was able to start and stop MySQL from Terminal or the Preference Pane when needed.
Occasionally, the Preference Pane failed to start/stop MySQL. In that case, I would enter the start/stop command in Terminal and it worked.
Start MySQL:
sudo /usr/local/mysql/support-files/mysql.server start
Stop MySQL:
sudo /usr/local/mysql/support-files/mysql.server stop
Download the .dmg file from MySQL and run the installer.
I did try downloading the .tar file, and it may have worked - but on my second try, I chose the .dmg file and everything went smoothly.
If you try to start MySQL at this point, it should run without a problem.
Remember, since at this point you have a clean install of MySQL, you can log in with the username 'root' and password 'no password' (leave password blank).
Please note that if you start MySQL from the terminal, you will get more information than trying from the Preference Pane, so if you are having difficulty, make sure you stop and start MySQL from Terminal. You will get some error messages that you use to troubleshoot the problem.
You can modify the .cnf and .plist files as mentioned in the installer instructions above (as long as you stop MySQL before making any changes).
Typically you would copy and paste the information from the web page (mentioned above) into the .cnf file. It is pretty straight forward, but double and triple check that the copy and paste did not miss a character or two. This happened to me while pasting the code into the .cnf file (the first two characters were missing) and it took me hours to figure this out - which prevented MySQL from starting.
If the changes to the .cnf or .plist file don't seem to take effect, restart the Mac (easier than restarting the process).
Moving your data.
My install created a /usr/local/mysql/ alias or symbolic link to the /usr/local/mysql/mysql-5.6.19-osx10.7-x86_64 directory.
The /usr/local/mysql/data directory (which is actually the /usr/local/mysql/mysql-5.6.19-osx10.7-x86_64/data directory - remember, it's a symbolic link) is where your data resides.
You want a backup of your previous data directory. If you forgot to back that up before running the installer, and you have a Time Machine backup, you can retrieve it.
The easiest way to do this is to open the /usr/local/ directory (From the Finder and choose "Go to Folder" from the Go menu) and with the /usr/local/ directory open in the Finder, choose Enter Time Machine from the Time Machine menu. Go back to the last known date that has your previous MySQL installation. Find the folder of your previous MySQL install and open the data directory.
You have to choose all the files from the exact same point in time. You can't choose one data folder from one day and one data folder from another (I actually did this and spent a lot of time trying to figure out why one of my data tables were visible in Sequel Pro but wouldn't work). After a while, I finally figured out that everything absolutely has to be from the exact same point in time.
You can copy files while in Time Machine by right-clicking on them. Choose all your data folders (with the .ibd and .frm files in them) PLUS all the ib_logfiles (ib_logfile0, ib_logfile1), auto.cnf, and the .pid file. Basically copy everything in the mysql data folder EXCEPT the mysql, performance_schema, and test directories.
Exit Time Machine.
Make sure MySQL is stopped and then paste the data files into the /usr/local/mysql/data directory.
Set the privileges to the data directory.
In Terminal, enter:
sudo chown -R mysql:mysql /usr/local/mysql/data
Make sure NOT to use the chmod 777 command as some people online said it can damage things.
Now, start MySQL and you should have your data files from your previous MySQL install intact and functional. In addition, I did not have to reset any passwords for Sequel Pro. The Sequel Pro settings saved before the Mavericks upgrade worked.
I'm currently trying to get MySQL working on OSX 10.7 Lion. I tried the brew way:
brew install mysql
-> cmake -> no problems
-> make -> no problems
-> make install -> no problems
-> done
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Installing MySQL system tables...
/usr/local/bin/mysql_install_db: line 428: 15397 Done { echo "use mysql;"; cat $create_system_tables $fill_system_tables; }
15398 Done(141) | eval "$filter_cmd_line"
15401 Segmentation fault: 11 | $mysqld_install_cmd_line > /dev/null
Installation of system tables failed! Examine the logs in
/usr/local/var/mysql for more information.
Did anyone get mysql to run on Lion?
You can download a MySQL installer as a DMG file, complete with an installer, system preferences pane and a startup script directly from MySQL. Go to MySQL's community server download page, select Mac OS X as the platform and pick the DMG file.
You can skip the registration form (there a little link under the signup form) and you should be on your way.
Once the file is downloaded, double-click on the DMG, launch the installer and complete the installation. After that, install the startup script using its installer and finally the preferences pane by double-clicking on it. I highly recommend choosing to install it for all users on the computer.
You'll find this way much easier than compiling from source.
You should check out Sequel Pro if you need a great OS X tool to manage your MySQL databases.
A drop in replacement for mysql is mariadb. You can install with 'brew install mariadb'. It builds on Lion.
Existing mysql drivers and clients just work. I'm using it with python-mysql and django.
It's even called mysql so you won't even know the difference.
Ha! Got it!
First... download mysql-5.6.2 here: http://dev.mysql.com/downloads/mirror.php?id=402349#mirrors ... once finished, untar the file and do this:
mv path/to/mysql-5.6.2-m5-osx10.6-x86_64 /usr/local/mysql
echo "PATH=\$PATH:/usr/local/mysql/bin" >> ~/.profile
# open a new tab
cd /usr/local/mysql #this is essential!
./scripts/mysql_install_db
mysqld_safe &
mysql -uroot
works for me :)
You need to set up your path environment too, and it's also good practise to set a root password while you're at it. I've created a full step-by-step here: How to install MySQL on Lion (Mac OS X )
All,
I was having issues with connecting to my DB through Tomcat, yet could through the MySql tool. Tomcat was accessing it through the actual IP of my machine (10.0.x.x) instead of through localhost or 127.0.0.1. Turns out that when I migrated from SL to Lion, remote connections were disabled. Once I enabled them, it worked fine.
Hopefully this helps someone.
I had MySQL installed already, but after upgrading to Lion it would no longer start.
I tried installing the latest official version and it still wouldn't start.
Finally, this fixed it:
$ sudo mkdir /var/log/mysql
$ sudo chown mysql:mysql /var/log/mysql
I've got a vanilla install of XAMPP in OS X. How can I access the mysql command line tool? I've tried typing "mysql" at the command line, and it spits back "-bash: mysql: command not found".
XAMPP is installed in Mac OS X in the following directory:
/Applications/XAMPP/
You can look what's inside that directory and run mysql command line tool providing the full path to it:
$ /Applications/XAMPP/xamppfiles/bin/mysql
If you need, you can modify your PATH environment variable to include XAMPP binaries and you won't need to specify the whole path all the time.
Open your .profile file in Mac. This can be done by entering the terminal and typing
pico ~/.profile
Add the following line to your ./profile file. Replace the path where you installed Xampp, however by default this is the route and should work:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH
Open a new terminal window (Recommendation is to quit all terminal windows and then reopen) and type:
mysql
That is all, isn't easy!!
Before using the mysql command, make sure that you start up the server first by running
$ mysql.server start
Then you will be able to use the commands mysqladmin and mysql.
To shut it down, run
$ mysql.server stop
and to restart just use
$ mysql.server restart
Very intuitive.
Open terminal and Follow this bellow step to add mysql to your mac environmental variable
step 1:
sudo nano ~/.bash_profile
step 2:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH
save it by control+x and then y and hit return. That's it!! now close the terminal and reopen
mysql --version
this will tell you which MySQL version you are using with xampp
Since I cannot comment on the accepted answer by Pablo Santa Cruz - Here's some additional info. If you're going to modify your PATH environment variable to include XAMPP binaries, make sure you add
/Applications/XAMPP/xamppfiles/bin
and not
/Applications/XAMPP/xamppfiles/bin/mysql
to the /etc/paths file. To do this run the command
sudo nano /etc/paths
then add the path to the file. Save using Ctrl+O and exit using Ctrl+X. Quit terminal and open again.