1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

Enable to create seahub database

This commit is contained in:
xiez
2012-03-23 14:09:06 +08:00
parent c5bb23c11e
commit b823080618
2 changed files with 19 additions and 6 deletions

View File

@@ -16,12 +16,17 @@ except:
sys.exit(1)
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()
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:
cursor.execute(cmd)
cursor.execute(create_cmd)
cursor.execute(grant_cmd)
except:
pass