MySQL 5.7 installation on Mac OS X El Capitan 10.11.4 - mysql

I am new to Mac OS X El Capitan 10.11.4. I tried installing MySQL 5.7.4 on MAC OS X from .dmg file that contains .pkg file. In the first time installation it prompted a root password (I am not sure if it prompted or I missed) but I missed noticing it.
I again run the MySQL installation but it does not prompted the root user password this time during installation. I tried setting root user password from previous Stack Overflow post but nothing seems to work. Can you explain me process to reset MySQL root user password or to reinstall MySQL so that it prompt the root user password?

I got the solution; here is step-by-step process to reset root password in MySQL:
Stop the mysqld server. This can be done by from 'System Preferences' > MySQL > 'Stop MySQL Server'
Start the server in safe mode with privilege bypass
From a terminal:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
In a new terminal window type:
sudo /usr/local/mysql/bin/mysql -u root
UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass')
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
\q
Stop the mysqld server again and restart it in normal mode.

What worked for me was, to uninstall the old 5.7 version (from the pkg installer) that didn't start and/or had issues showing the root password, and install the same version with brew.
1) Remove the remnants of the old installation.
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
Use sudo at your own discretion, never copy paste commands from random
people
2) Then proceed to install with brew.
$ brew update
$ brew info mysql#5.7
Expected output: mysql#5.7: stable 5.7.XX (bottled) [keg-only]
$ brew install mysql#5.7
$ echo 'export PATH="/usr/local/opt/mysql#5.7/bin:$PATH"' >> ~/.bash_profile
Because this is keg only, we need to manually put mysql in our PATH
$ mysql.server start
$ mysql.server stop
Use these commands to start/stop mysql
$ mysql_secure_installation
That was what I had to do to make it work.

Related

MySQL installed via HomeBrew Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I've been searching for hours about this issue i'm having.
I have installed mysql#5.7 in my mac osx Monterey 12.0.1 with M1 chip using Homebrew.
I've been following this tutorial that helped me install mysql version 5.7. I'm specifying this version because i'm recreating a production environment on local.
At the step where I need to secure my mysql installation I type user root password and get this error Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
I have read many ways to fixing this but I can't make it work with any of those because most of them don't relate to homebrew or don't work well for me.
I have the service running using the brew services start mysql#5.7 command and this doesn't seem fixing the issue.
Is there any possibility I can't make it run because I have an M1 chip?
I researched again and remembered that I had previously installed a MySQL 8.X version. I uninstalled it only using the brew uninstall command. This wasn't enough and I made sure I deleted all the mysql related files and folders from my computer.
After that I retried installing MySQL 5.7 as a completely fresh install. Then at this same step where I had trouble before I didn't have any issue, I followed the installation and now is up and running.
These are all the files I found were related to other MySQL installations, you may or may not have them in your system but I suggest to try delete them all, here I paste the commands needed:
ps -ax | grep mysql
stop and kill any MySQL processes
brew remove mysql
brew cleanup
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
/opt/homebrew/var/mysql
/opt/homebrew/etc/my.cnf
Do you have the mysql.sock in your /tmp?
You can make a symlink, depending on your installation
ln -s /var/mysql/mysql.sock /tmp/mysql.sock

"Cannot load from mysql.procs_priv. The table is probably corrupted" on Osx / homebrew

Problem:
Getting Cannot load from mysql.procs_priv. The table is probably corrupted when trying to create new mysql user.
Platform: OSX Yosemite, Homebrew
Tried all the below and DID NOT WORK:
Upgrading: mysql_upgrade -uroot -p
I had to use --force because of this: This installation of MySQL is already upgraded to 5.7.9, use --force if you still need to run mysql_upgrade
Next I had to use --skip-version-check because of this: Error: Server version (5.7.18) does not match with the version of the server (5.7.9) with which this program was built/distributed. You can use --skip-version-check to skip this check.
still didn't work after all that
Reducing the query to most obvious and taking out functions: CREATE USER 'newuser';, still throws same error.
Repairing the mysql.procs_priv table
Changing all the char columns in mysql.procs_priv to varchar, as suggested here. Well he suggested changing to text but that seemed too crazy for a core mysql table.
I think it will be better to use this:
mysql_upgrade -u root -p
Enter your password and wait a few seconds.
Completely removing mysql and reinstalling it worked (less than 15 mins).
1. UNINSTALL AND PURGE MYSQL FROM SYSTEM
Back up databases.
Stop and kill any MySQL processes. Check for processes with ps -ax | grep mysql
Uninstall mysql
brew remove mysql
brew cleanup
Remove all the residual files
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
Unload previous auto login
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Remove previous config. Delete the line MYSQLCOM=-YES- from /etc/hostconfig
Remove previous preferences
sudo rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
sudo rm -rf /private/var/db/receipts/*mysql*
sudo rm -rf /private/var/mysql
Optional, restart computer. I didn't.
2. INSTALL MYSQL
Install Mysql
brew install mysql
Set to run on startup
brew services start mysql
Secure the installation
mysql_secure_installation

Install MySQL 5.5 in Ubuntu 11.10

I have been downloaded the DEB package of mysql 5.5.23.
Install MySQL by the command as follows:
sudo dpkg -i mysql-5.5.23-debian6.0-x86_64.deb
The result said that installed successfully.
But when I type the command:
sudo service mysql start
Or
mysql
It shows me that "mysql: unrecognized service" or "mysql: command not found".
Besides, I can't find MySQL files in "/usr/include" or "/usr/bin"
Please help me. Thx.
Because MySQL 5.5.x is not packaged, in repositories only exist 5.1.x
This worked for me:
http://www.rebojo.com/debian-installing-mysql/
Why not a simple command :
sudo apt-get install mysql-server
MySQL Download URL
https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Open the terminal and follow along:
Uninstall any existing version of MySQL
sudo rm /var/lib/mysql/ -R
Delete the MySQL profile
sudo rm /etc/mysql/ -R
Automatically uninstall mysql
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
Download version 5.5.51 from MySQL site
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Add mysql user group
sudo groupadd mysql
Add mysql (not the current user) to mysql user group
sudo useradd -g mysql mysql
Extract it
sudo tar -xvf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
Move it to /usr/local
sudo mv mysql-5.5.56-linux-glibc2.5-x86_64 /usr/local/
Create mysql folder in /usr/local by moving the untarred folder
cd /usr/local
sudo mv mysql-5.5.49-linux2.6-x86_64 mysql
set MySql directory owner and user group
cd mysql
sudo chown -R mysql:mysql *
Install the required lib package (works with 5.6 as well)
sudo apt-get install libaio1
Execute mysql installation script
sudo scripts/mysql_install_db --user=mysql
Set mysql directory owner from outside the mysql directory
sudo chown -R root .
Set data directory owner from inside mysql directory
sudo chown -R mysql data
Copy the mysql configuration file
sudo cp support-files/my-medium.cnf /etc/my.cnf
Start mysql
sudo bin/mysqld_safe --user=mysql &
sudo cp support-files/mysql.server /etc/init.d/mysql.server
Set root user password
sudo bin/mysqladmin -u root password '[your new password]'
Add mysql path to the system
sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
Reboot!
Start mysql server
sudo /etc/init.d/mysql.server start
Stop mysql server
sudo /etc/init.d/mysql.server stop
Check status of mysql
sudo /etc/init.d/mysql.server status
Enable myql on startup
sudo update-rc.d -f mysql.server defaults
*Disable mysql on startup (Optional)
`sudo update-rc.d -f mysql.server remove`
REBOOT!
Now login using below command, start mysql server if it's not running already
mysql -u root -p

Change MySQL Port - Mac - MAMP

I previously had MySQL installed on my Mac before I installed MAMP. So before I installed MAMP, I removed my older version of MySQL using the following terminal commands:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm /etc/my.cnf
However when I try and run the MySQL server using MAMP with the default port of 3306, it will not connect. I get the error:
2002: Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2) when trying to connect
But when I use any other port I am able to run MySQL server. So I have come to the conclusion that my older version of MySQL is still somehow hogging the default port.
Does anyone have a clue how to rid of this? Thanks.
If you are correct that the old MySQL server is hogging the port, you can try to locate the process and kill it. But the easiest solution might be the nuclear option: Reboot your Mac.
If that doesn't solve it, then the problem is not the old version of MySQL hogging the port...

How do you uninstall MySQL from Mac OS X?

I accidentally installed the PowerPC version of MySQL on my Intel Mac in Snow Leopard, and it installed without a problem but of course doesn't run properly. I just didn't pay enough attention. Now when I try to install the correct x86 version it says that it can't install because a newer version is already installed. A Google query led me to perform these actions/delete these files to uninstall it:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySQL*
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
And finally removed the line MYSQLCOM=-YES- from /etc/hostconfig
They haven't seemed to help at all. I am still receiving the same message about there being a newer version. I tried installing an even newer version (the current Beta) and it also gave me the same message about a newer version already being installed. I can't uninstall it from the Prefs Pane because I never installed the PrefPane also.
Try running also
sudo rm -rf /var/db/receipts/com.mysql.*
I also had entries in:
/Library/Receipts/InstallHistory.plist
that i had to delete.
If you installed mysql through brew then we can use command to uninstall mysql.
$ brew uninstall mysql
Uninstalling /usr/local/Cellar/mysql/5.6.19...
This worked for me.
ps -ax | grep mysql
*stop and kill any MySQL processes
brew remove mysql
brew cleanup
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySql*
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
*restart your computer just to ensure any MySQL processes are killed
try to run mysql, it shouldn't work
OS version: 10.14.6
MYSQL version: 8.0.14
Goto System preferences -> MYSQL
Stop MySQL server
One option will be shown here to uninstall MYSQL 8 after stopping Mysql server
Aside from the long list of remove commands in your question, which seems quite comprehensive in my recent experience of exactly this issue, I found mysql.sock running in /private/var and removed that. I used
find / -name mysql -print 2> /dev/null
...to find anything that looked like a mysql directory or file and removed most of what came up (aside from Perl/Python access modules). You may also need to check that the daemon is not still running using Activity Monitor (or at the command line using ps -A). I found that mysqld was still running even after deleting the files.
I also had a config file at /etc/my.cnf that I needed to delete on my Mac OS X Snow Leopard install
It might be overkill but your MySQL command history can also be wiped from:
~/.mysql_history
You need to identify where MySQL was installed to before attempting to delete it.
I always use the Hivelogic guide to installing under Mac OS X which builds MySQL from source. When setting up the build you can specify a directory under which to install MySQL with the --prefix parameter. You should make sure the directory does not exist and attempt to install from source.
./configure --prefix=/usr/local/mysql --with-extra-charsets=complex \
--enable-thread-safe-client --enable-local-infile --enable-shared \
--with-plugins=innobase
You should also check /var/db/receipts and remove all entries that contain com.mysql.*
Using sudo rm -rf /var/db/receipts/com.mysql.* didn't work for me. I had to go into var/db/receipts and delete each one seperately.
For me, I had installed MariaDB years ago using homebrew. Correct uninstall procedure was:
brew uninstall mariadb.
I also found
/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
after using all of the other answers here to uninstall MySQL Community Server 8.0.15 from OS X 10.10.
This did the job for me:
brew uninstall mysql
brew uninstall --force mysql#<version_no>
exmample
brew uninstall --force mysql#5.7
to get version check cd /usr/local/Cellar
Remove MySQL completely
Open the Terminal
Use mysqldump to backup your databases
Check for MySQL processes with:
ps -ax | grep mysql
Stop and kill any MySQL processes
Analyze MySQL on HomeBrew:
brew remove mysql
brew cleanup
Remove files:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
Unload previous MySQL Auto-Login:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Remove previous MySQL Configuration:
subl /etc/hostconfig`
# Remove the line MYSQLCOM=-YES-
Remove previous MySQL Preferences:
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
Restart your computer just to ensure any MySQL processes are killed
Try to run mysql, it shouldn't work
sudo find / | grep -i mysql
This worked like a charm for me. Just went through the list and ensured that anything MySQL related was deleted.