jupyter / help

:sparkles: Need some help or have some questions? Please visit our Discourse page.
https://discourse.jupyter.org
291 stars 97 forks source link

mysql kernel on jupyter #179

Open sekigh opened 7 years ago

sekigh commented 7 years ago

I want to build an environment on my PC where mysql and python running on jupyter notebook by changing kernel. I already have python3.6 on jupyter notebook running properly on ubuntu 16.04 as guest OS with Windows10 as host OS via Virtualbox. I added mysql and related kernel to jupyter notebook but jupyter's kernel to mysql try to connect with mysql but immedelately dies with several automatic trials in vain. Is there any advice to fix this problem ?

What I did to install mysql and related library is as follows;

1) I installed mysql5.7.18 server on ubuntu 16.04 guest OS, set up root and user, and then can use mysql in user mode to localhost properly! The following is the procedure to take;

$ sudo apt-get install mysql-server $ sudo vi my.cnf !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/

[client] default-character-set = utf8

[mysqld] skip-character-set-client-handshake character-set-server = utf8 collation-server = utf8_general_ci init-connect = SET NAMES utf8

$ sudo service mysql restart $ mysql -u root -p mysql> CREATE USER xxxx IDENTIFIED BY 'password';

mysql> status

mysql Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper

Connection id: 7 Current database:
Current user: xxxxxx @localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 2 hours 58 min 12 sec

Threads: 1 Questions: 24 Slow queries: 0 Opens: 110 Flush tables: 1 Open tables: 29 Queries per second avg: 0.002

2) I Installed mysql kernel for jupyter (IPython) according to instruction below, as listed in URL: https://github.com/mmisono/ipython_mysql_kernel.

$ pip install pip install git+https://github.com/mmisono/ipython_mysql_kernel <This installs kernel.py under ~/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packages/ipython_mysql_kerne>

3) Create associated parameters in two files as follow; 3.1) Create kernel.json under ~/,ipython/mysql/

$ vi kernel.json { "argv": [ "python", "~/.pyenv/versions/anaconda3-4.3.0/lib/python3.6/site-packageS/ipython_mysql_kernel/kernel.py", "-f", "{connection_file}" ], "display_name": "mysql" }

3.2) Create mysql_config.json under ~/.ipython/

$ vi mysql_config.json

{ "user" : "sekigh@localhost" "port" : "3306" "host" : "localhost" "charset: "utf8" }

  1. Launch jupyter notebook and select mysql kerenl from top-right new icon to draw " mysql" . jupyter kernel tries to connect with mysql and looks connected once but immdeately dies with several automatic re-trial in vain.

  2. Additional information; I set up python3.6 and jupyter environment by pyenv and anaconda3-4.3.0 under ubuntu.

Thank you for advice in advance. Hiroshi Sekiguchi

< End of text>

minrk commented 7 years ago

If you have set a password on mysql, I think you also need to include this as "password": "your password" in mysql_config.json.

sekigh commented 7 years ago

I added the statement "password" : "my_password" in mysql_config.json but the phenomena doesn't change at all. I tried to change "user" to "root" and "password" to proper password but the phenomena does not change either.