コード例 #1
0
ファイル: mysql.py プロジェクト: pywizard/pywizard-book-mysql
    def init_root_password():
        root_password = get_password_for_user('mysql', 'root', purpose='Password for mysql server')

        if is_ubuntu():
            run('echo mysql-server mysql-server/root_password password \'%s\' | debconf-set-selections' % root_password,
                secrets=(root_password,))
            run('echo mysql-server mysql-server/root_password_again password \'%s\' | debconf-set-selections' % root_password,
                secrets=(root_password,))
コード例 #2
0
ファイル: mysql.py プロジェクト: pywizard/pywizard-book-mysql
    def init_root_password():
        root_password = get_password_for_user('mysql', 'root', purpose='Password for mysql server')

        root_password = subprocess.list2cmdline([root_password])

        if is_ubuntu():
            run('echo mysql-server mysql-server/root_password password %s | debconf-set-selections' % root_password,
                secrets=[])
            run('echo mysql-server mysql-server/root_password_again password %s | debconf-set-selections' % root_password,
                secrets=(root_password,))
コード例 #3
0
ファイル: mysql.py プロジェクト: pywizard/pywizard-book-mysql
def mysql_server(**kwargs):

    require_sudo(reason='Only root can install mysql server.')

    def init_root_password():
        root_password = get_password_for_user('mysql', 'root', purpose='Password for mysql server')

        root_password = subprocess.list2cmdline([root_password])

        if is_ubuntu():
            run('echo mysql-server mysql-server/root_password password %s | debconf-set-selections' % root_password,
                secrets=[])
            run('echo mysql-server mysql-server/root_password_again password %s | debconf-set-selections' % root_password,
                secrets=(root_password,))

    def init_root_password_():
        root_password = get_password_for_user('mysql', 'root', purpose='Password for mysql server')
        if is_centos():
            run("service mysqld start")
            run("mysqladmin -u root password '%s'" % root_password)

    package('mysql-server', before_install=init_root_password, after_install=init_root_password_)

    if is_centos():
        mysql_service_name = 'mysqld'
        my_cnf = '/etc/my.cnf'
    elif is_ubuntu():
        mysql_service_name = 'mysql'
        my_cnf = '/etc/mysql/my.cnf'
    else:
        raise NotImplemented

    mysql_service = service(mysql_service_name, process_name='mysqld', start=True)

    def restart():
        mysql_service.restart()

    if is_centos():
        shell('/sbin/chkconfig mysqld on')