简体   繁体   中英

mysql.server command not found and jupyter notebook

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM