This procedure explains how to install MySQL and MySQL Workbench using Homebrew on macOS. This is a fork of these instructions, to make them more concise and solve the issues reported here.
To install MySQL enter :
- brew install mysql
- brew services start mysql
- then run mysql_secure_installationand follow the instructions
install via HomeBrew Cask: brew cask install mysqlworkbench
- install brew install phpmyadmin
- edit /private/etc/apache2/httpd.conffile assudo
- add below code block at the end:
Alias /phpmyadmin /usr/local/share/phpmyadmin
    <Directory /usr/local/share/phpmyadmin/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        <IfModule mod_authz_core.c>
            Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            Order allow,deny
            Allow from all
        </IfModule>
    </Directory>
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
and make sure you have the line:
DirectoryIndex index.html index.php home.pl index.cgi
- then sudo apachectl restart
- Install MySQL plugin
- run mysql - u <user> -pto entermysql
- run ALTER USER '<user>'@'<server>' IDENTIFIED WITH mysql_native_password BY '<password>';
- if your password is not accepted:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
- run SHOW VARIABLES LIKE 'validate_password%';to see the password policies
- run SET GLOBAL <Variable_name> = <New_Value>;to change
- install pip3 install mysql-connector
- run the blow code to test your Python connection:
import mysql.connector
mydb = mysql.connector.connect(
    host="localhost",
    user="<user>",
    passwd="<password>",
    auth_plugin='mysql_native_password',
)
print(mydb)and using Pandas to run and fetch the results of MySQL queries:
df = pd.read_sql_query("SELECT * FROM <table>", mydb)
df.head()- Install pip3 install ipython-sql
- pip3 install mysqlclient
- now you should be able to run these cells and get pretty-printed HTML output:
# %%
%load_ext sql
# %%
%sql mysql+mysqldb://<user>:<password>@localhost/<dataBase>
# %%
%%sql
SELECT *
FROM <table>;