Reputation: 48
My understanding is that when I downloaded MAMP that mysql would've been automatically downloaded as well.
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!
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!
Upvotes: 0
Views: 504
Reputation: 332
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.
Upvotes: 1