標籤:狀態 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資料庫