mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 10:22:46 +00:00
Enable to create seahub database
This commit is contained in:
@@ -16,12 +16,17 @@ except:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def do_create():
|
def do_create():
|
||||||
conn = MySQLdb.Connect(host='localhost', user=dbuser, passwd=dbpasswd)
|
root_passwd = raw_input("Please enter root password to create database %s: " % dbname)
|
||||||
|
|
||||||
|
conn = MySQLdb.Connect(host='localhost', user='root', passwd=root_passwd)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
cmd = ( "CREATE DATABASE IF NOT EXISTS `%s` default charset utf8 COLLATE utf8_general_ci;") % (dbname)
|
create_cmd = ( "CREATE DATABASE IF NOT EXISTS `%s` default charset utf8 COLLATE utf8_general_ci;") % (dbname)
|
||||||
|
grant_cmd = ("grant all privileges on %s.* to '%s'@localhost identified by '%s';") % (dbname, dbuser, dbpasswd)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cursor.execute(cmd)
|
cursor.execute(create_cmd)
|
||||||
|
cursor.execute(grant_cmd)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@@ -9,8 +9,11 @@ export PYTHONPATH=/usr/lib/python2.6/site-packages:thirdpart
|
|||||||
|
|
||||||
# The database configuration. Change to your config
|
# The database configuration. Change to your config
|
||||||
export DBNAME='seahub-meta'
|
export DBNAME='seahub-meta'
|
||||||
export DBUSER='root'
|
export DBUSER='seafile-user'
|
||||||
export DBPASSWD='test'
|
export DBPASSWD='seafile'
|
||||||
|
|
||||||
|
# Save sqlite settings
|
||||||
|
cp settings.py setting.py.sqlite
|
||||||
|
|
||||||
# Delete the exist seahub tables in database
|
# Delete the exist seahub tables in database
|
||||||
python batch-delete.py
|
python batch-delete.py
|
||||||
@@ -34,4 +37,9 @@ sed -i "/DATABASE_PASSWORD/c\DATABASE_PASSWORD = '$DBPASSWD'" $SETTINGS_COPY
|
|||||||
|
|
||||||
./manage.py dumpdata --format=xml > $DUMP_FILE --settings=settings && ./manage.py loaddata $DUMP_FILE --settings=$SETTINGS_MODULE && echo '[DONE]' || echo '[FAILED]'
|
./manage.py dumpdata --format=xml > $DUMP_FILE --settings=settings && ./manage.py loaddata $DUMP_FILE --settings=$SETTINGS_MODULE && echo '[DONE]' || echo '[FAILED]'
|
||||||
|
|
||||||
#rm $DUMP_FILE $SETTINGS_COPY 2> /dev/null
|
# Save mysql settings, and use it as curernt settings
|
||||||
|
cp $SETTINGS_COPY settings.py.mysql
|
||||||
|
cp $SETTINGS_COPY settings.py
|
||||||
|
|
||||||
|
# Remove temp file
|
||||||
|
rm $DUMP_FILE $SETTINGS_COPY 2> /dev/null
|
||||||
|
Reference in New Issue
Block a user