superset連結本地mysql資料庫

來源:互聯網
上載者:User

標籤:狀態   init   logs   manager   primary   查看   color   asc   ase   

  剛安裝好superset的時候大家都知道是用的其自動產生的sqllite資料庫,如果我們想讓器連結到自己資料庫,給大家分享一下我的方法,以mysql為例:

1.安裝好資料庫mysql:

$ sudo apt-get install mysql-server

$ sudo apt-get install mysql-client

$ sudo apt-get install libmysqlclient-dev

安裝過程中需要設定啟動mysql密碼,必須記住。

2.啟動mysql,並建立資料庫

$ mysql -u root -p

輸入密碼加入以後,命令:

mysql> create database teamwork

teamwork為庫名

然後操作資料庫,可以用寫好的sql指令檔:

drop database `teamwork`;create database `teamwork`;use `teamwork`;create table `teams`(`team_id` int(11) not null auto_increment, `team_name` varchar(50) not null, `team_intro` varchar(500) not null, `team_builderid` int(11) not null, primary key(`team_id`), key `team_ibfk_1` (`team_builderid`), constraint `team_ibfk_1` foreign key (`team_builderid`) references `users` (`user_id`) on delete cascade on update cascade)engine = innodb default charset=utf8;insert into teams values (1,‘團隊1‘,‘籃球群‘,‘1‘), (2,‘團隊2‘,‘興趣愛好‘,‘1‘),(3,‘團隊3‘,‘群‘,‘1‘),(4,‘團隊4‘,‘籃球群‘,‘2‘);

將這個檔案儲存為teamwork.sql,終端執行命令:

$ mysql -u root -p teamwork</home/jiang/py3env/teamwork.sql

上面的命令是在資料庫teamwork中執行sql檔案,注意/home/wang/py3env/teamwork.sql為存放路徑,teamwork是已有的資料庫。

輸入密碼後可鍵入命令,查看是否成功:

mysql> show database;

mysql> use teamwork;

mysql> show tables;

3.配置superset設定檔,config.py

將原資料庫改為myqsl。

4.重新設定登入帳號

  這個時候資料庫是新的狀態,之前在sqlite中的登入帳號已經沒有了需要重新設定一下:

$ (py3env)[email protected]:~/py3env$ fabmanager create-admin --app superset

$ (py3env)[email protected]:~/py3env$ superset db upgrade

$ (py3env)[email protected]:~/py3env$ superset init

注意這些操作都是在虛擬環境啟用的情況下完成的。

這個時候重新啟動superset就完成了:

$ (py3env)[email protected]:~/py3env$ superset runserver

具體這個東西怎麼用,後面在研究補充。。。

 

superset連結本地mysql資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.