In the previous article, we have learned how to install MySQL Server on a Mac. I was running macOS Catalina on a Hackintosh system. It runs very well until now. But for some reason, I have to remove or uninstall the MySQL Server from my Hackintosh system. Well, there are some easy steps to uninstall MySQL Server from macOS Catalina.
I’m trying to setup up MySQL on mac os 10.6 using Homebrew by brew install mysql 5.1.52.
Everything goes well and I am also successful with the mysql_install_db.
However when I try to connect to the server using:
I get:
I’ve tried to access mysqladmin or mysql using -u root -proot as well,
but it doesn’t work with or without password.
This is a brand new installation on a brand new machine and as far as I know the new installation must be accessible without a root password. I also tried:
but I also get
I think one can end up in this position with older versions of mysql already installed. I had the same problem and none of the above solutions worked for me. I fixed it thus:
Used brew’s remove
& cleanup
commands, unloaded the launchctl
script, then deleted the mysql directory in /usr/local/var
, deleted my existing /etc/my.cnf
(leave that one up to you, should it apply) and launchctl plist
Updated the string for the plist. Note also your alternate security script directory will be based on which version of MySQL you are installing.
Step-by-step:
I then started from scratch:
brew install mysql
ran the commands brew suggested: (see note: below)
Start mysql with mysql.server start
command, to be able to log on it
Used the alternate security script:
Followed the launchctl
section from the brew package script output such as,
Note: the --force
bit on brew cleanup
will also cleanup outdated kegs, think it’s a new-ish homebrew feature.
Note the second: a commenter says step 2 is not required. I don’t want to test it, so YMMV!
Here are detailed instructions combining getting rid of all MySQL from your Mac then installing it The Brew Way as Sedorner wrote above:
ps -ax | grep mysql
kill
any MySQL processessudo 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
/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*
sudo rm -rf /tmp/mysql*
mysql
, it shouldn’t workbrew doctor
and fix any errors
brew remove mysql
brew cleanup
brew update
brew install mysql
unset TMPDIR
mysql.server start
run the commands Brew suggests, add MySQL to launchctl
so it automatically launches at startup
mysql
should now work and be running all the time as expected
Godspeed.
Had the same problem. Seems like there is something wrong with the set up instructions or the initial tables that are being created. This is how I got mysqld running on my machine.
If the mysqld server is already running on your Mac, stop it first with:
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
Start the mysqld server with the following command which lets anyone log in with full permissions.
mysqld_safe --skip-grant-tables
Then run mysql -u root
which should now let you log in successfully without a password. The following command should reset all the root passwords.
UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;
Now if you kill the running copy of mysqld_safe and start it up again without the skip-grant-tables option, you should be able to log in with mysql -u root -p
and the new password you just set.
If brew installed MySQL 5.7, the process is a bit different than for previous versions.
In order to reset the root password, proceed as follows:
A temporary password will be printed to the console and it can only be used for updating the root password:
Okay I had the same issue and solved it. For some reason the mysql_secure_installation script doesn’t work out of the box when using Homebrew to install mysql, so I did it manually. On the CLI enter:
That should get you into mysql. Now do the following (taken from mysql_secure_installation):
Now exit and get back into mysql with: mysql -u root -p
I had the same problem just now. If you brew info mysql
and follow the steps it looks like the root password should be new-password
if I remember correctly. I was seeing the same thing you are seeing. This article helped me the most.
It turned out I didn’t have any accounts created for me. When I logged in after running mysqld_safe
and did select * from user;
no rows were returned. I opened the MySQLWorkbench with the mysqld_safe
running and added a root
account with all the privs I expected. This are working well for me now.
Stop mysql completely.
mysql.server stop
<– may need editing based on your versionps -ef | grep mysql
<– lists processes with mysql in their namekill [PID]
<– kill the processes by PIDRemove files. Instructions above are good. I’ll add:
sudo find /. -name '*mysql*'
rm -rf
these files. Note that many programs have drivers for mysql which you do not want to remove. For example, don’t delete stuff in a PHP install’s directory. Do remove stuff in its own mysql directory.Hopefully you have homebrew. If not, download it.
I like to run brew as root, but I don’t think you have to. Edit 2018: you can’t run brew as root anymore Relux tunnel crack.
sudo brew update
sudo brew install cmake
<– dependency for mysql, usefulsudo brew install openssl
<– dependency for mysql, usefulsudo brew info mysql
<– skim through this… it gives you some idea of what’s coming nextsudo brew install mysql --with-embedded; say done
<– Installs mysql with the embedded server. Tells you when it finishes (my install took 10 minutes)sudo chown -R mysql /usr/local/var/mysql/
<– mysql wouldn’t work for me until I ran this commandsudo mysql.server start
<– once again, the exact syntax may varybrew info mysql
mysql.service start
or mysql -u root
I’m looking for a solution for some time but I can not solve my problem. I tried several solutions in stackoverflow.com but no this helping me.
TL;DR
MySQL server might not be running after installation with Brew. Try brew services start mysql
or just mysql.server start
if you don’t want MySQL to run as a background service.
Full Story:
I just installed MySQL (stable) 5.7.17 on a new MacBook Pro running Sierra and also got an error when running mysql_secure_installation
:
Say what?
According to the installation info from Brew, mysql_secure_installation
should prompt me to… secure the installation. I figured the MySQL server might not be running and rightly so. Running brew services start mysql
and then mysql_secure_installation
worked like a charm.
Here is an update for MySQL 5.7
Here is my definitive guide to getting a local web server running on macOS 10.15 “Catalina”. This is meant to be a development platform so that you can build and test your sites locally, then deploy to an internet server. This User Tip only contains instructions for configuring the Apache server, PHP module, and Perl module. I have another User Tip for installing and configuring MySQL and email servers.
Note: This user tip is specific to macOS 10.15 “Catalina”. Pay attention to your OS version. There have been significant changes since earlier versions of macOS. Another note: These instructions apply to the client versions of OS X, not Server. Server does a few specific tricks really well and is a good choice for those. For things like database, web, and mail services, I have found it easier to just setup the client OS version manually.
Requirements:
Optional: Xcode is required for adding PHP modules.
Lines in bold are what you will have to type in. Lines in bold courier should be typed at the Terminal.Replace <your short user name> with your short user name.
Here goes.. Enjoy!
To get started, edit the Apache configuration file as root:
sudo vi /etc/apache2/httpd.conf
Enable PHP by uncommenting line 186, changing:
#LoadModule php7_module libexec/apache2/libphp7.so
to
LoadModule php7_module libexec/apache2/libphp7.so
(If you aren't familiar with vi, go to line 186 by typing '186G' (without the quotes). Then just press 'x' over the '#' character to delete it. Then type ':w!' to save, or just 'ZZ' to save and quit. Don't do that yet though. More changes are still needed.)
If you want to run Perl scripts, you will have to do something similar:
Enable Perl by uncommenting line 187, changing:
#LoadModule perl_module libexec/apache2/mod_perl.so
to
LoadModule perl_module libexec/apache2/mod_perl.so
Enable personal websites by uncommenting the following at line 183:
#LoadModule userdir_module libexec/apache2/mod_userdir.so
to
LoadModule userdir_module libexec/apache2/mod_userdir.so
and do the same at line 520:
#Include /private/etc/apache2/extra/httpd-userdir.conf
to
Include /private/etc/apache2/extra/httpd-userdir.conf
Now save and quit.
Open the file you just enabled above with:
sudo vi /etc/apache2/extra/httpd-userdir.conf
and uncomment the following at line 16:
#Include /private/etc/apache2/users/*.conf
to
Include /private/etc/apache2/users/*.conf
Save and exit.
Lion and later versions no longer create personal web sites by default. If you already had a Sites folder in Snow Leopard, it should still be there. To create one manually, enter the following:
mkdir ~/Sites
echo '<html><body><h1>My site works</h1></body></html>' > ~/Sites/index.html.en
While you are in /etc/apache2, double-check to make sure you have a user config file. It should exist at the path: /etc/apache2/users/<your short user name>.conf.
That file may not exist and if you upgrade from an older version, you may still not have it. It does appear to be created when you create a new user. If that file doesn't exist, you will need to create it with:
sudo vi /etc/apache2/users/<your short user name>.conf
Use the following as the content:
<Directory '/Users/<your short user name>/Sites/'>
AddLanguage en .en
AddHandler perl-script .pl
PerlHandler ModPerl::Registry
Options Indexes MultiViews FollowSymLinks ExecCGI
AllowOverride None
Require host localhost
</Directory>
Now you are ready to turn on Apache itself. But first, do a sanity check. Sometimes copying and pasting from an internet forum can insert invisible, invalid characters into config files. Check your configuration by running the following command in the Terminal:
apachectl configtest
If this command returns 'Syntax OK' then you are ready to go. It may also print a warning saying 'httpd: Could not reliably determine the server's fully qualified domain name'. You could fix this by setting the ServerName directive in /etc/apache2/httpd.conf and adding a matching entry into /etc/hosts. But for a development server, you don't need to do anything. You can just ignore that warning. You can safely ignore other warnings too.
Turn on the Apache httpd service by running the following command in the Terminal:
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
In Safari, navigate to your web site with the following address:
It should say:
It works!
Now try your user home directory:
http://localhost/~<your short user name>
It should say:
My site works
Now try PHP. Create a PHP info file with:
echo '<?php echo phpinfo(); ?>' > ~/Sites/info.php
And test it by entering the following into Safari's address bar:
http://localhost/~<your short user name>/info.php
You should see your PHP configuration information.
To test Perl, try something similar. Create a Perl test file with:
echo 'print $ENV{MOD_PERL} . qq{n};' > ~/Sites/info.pl
And test it by entering the following into Safari's address bar:
http://localhost/~<your short user name>/info.pl
You should see the string 'mod_perl/2.0.9'.
If you want to setup MySQL, see my User Tip on Installing MySQL.
If you want to add modules to PHP, I suggest the following site. I can't explain it any better.
If you want to make further changes to your Apache system or user config files, you will need to restart the Apache server with:
sudo apachectl graceful