0

My understanding is that when I downloaded MAMP that mysql would've been automatically downloaded as well.

  1. I have changed the PATH in the bash_profile to "Applications/MAMP/Library/bin" and then I tested the command "mysql --version", which works perfectly, but then I tried to run "mysql.server start" it prompted "mysql.server command not found" (sudo mysql.server results the same thing). I'm confused because obviously that mysql is found, otherwise "mysql --version" wouldn't work. Please help me figure this out, thanks!

  2. My final goal is to be able to access my database on Jupyter Notebook.

    %load_ext sql no error;

    %sql mysql+mysqldb://myusername:fakepassword@localhost/company gives (MySQLdb._exceptions.OperationalError) (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

    Given the error above, I tried the following method to connect and resulted error as well:

  import mysql.connector
  db = mysql.connector.connect(
  host='localhost',
  user='myusername',
  passwd='fakepassword')

Error 2003 (HY000): Can't connect to MySQL server on 'localhost' (61)

Thanks in advance!

1 Answers1

1

mysql.server start seems to be the command for native MySQL. It is not for the MySQL from MAMP. From what I found online, to start MySQL server of MAMP, you can just use the GUI (see https://documentation.mamp.info/en/MAMP-Mac/First-Steps/)

From what I understand MAMP seems to only make the MySQL available via port (not through socket). So for the jupyter notebook try adding the port number like this:

%sql mysql+mysqldb://myusername:fakepassword@localhost:33060/company 

For the Python code try add the port number like this:

import mysql.connector
db = mysql.connector.connect(
    host='localhost',
    port=33060,
    user='myusername',
    passwd='fakepassword'
)

if the port number is different in MAMP, try the other port instead.

  • Thanks for the reply. The latter method worked after I added the port. However, the first one returns the same error even after added the port number. The reason I want to get the first one to work is because I want to be able to use the following code `%%sql SELECT * FROM department`. – Chameleon_7 Apr 30 '20 at 00:14
  • Found the solution for the problem: https://stackoverflow.com/questions/22436028/cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock-2. for MAMP user, open terminal and paste the following into terminal `ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock` – Chameleon_7 Apr 30 '20 at 00:32