fastmonkeys / stellar

Fast database snapshot and restore tool for development
MIT License
3.86k stars 119 forks source link

MySQL snapshot didn't work. #10

Closed epicserve closed 9 years ago

epicserve commented 10 years ago

I've anonymized settings bellow.

Here is my stellar.yaml file.

project_name: 'my_db_name'
tracked_databases: ['my_db_name']
url: 'mysql+pymysql://my_db_username:******************@localhost/'
stellar_url: 'mysql+pymysql://my_db_username:******************@localhost/stellar_data'

Here is my command line session.

(my-project) ❯ stellar init
Please enter the url for your database.

For example:
PostreSQL: postgresql://localhost:5432/
MySQL: mysql+pymysql://root@localhost/: mysql+pymysql://my_db_username:******************@localhost/
You have the following databases: information_schema, my_db_name, test, test_my_db_name
Please enter the name of the database (eg. projectdb): my_db_name
Please enter your project name (used internally, eg. my_db_name) [my_db_name]:
Wrote stellar.yaml

Warning: MySQL support is still in beta.
Tip: You probably want to take a snapshot: stellar snapshot
(my-project)
brento@my-host ~/Sites/my-project-django (responses!)
(my-project-django) ❯ stellar snapshot
Traceback (most recent call last):
  File "/Users/brento/.virtualenvs/my-project/bin/stellar", line 9, in <module>
    load_entry_point('stellar==0.3.1', 'console_scripts', 'stellar')()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/stellar/command.py", line 225, in main
    stellar()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/click/core.py", line 572, in __call__
    return self.main(*args, **kwargs)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/click/core.py", line 552, in main
    rv = self.invoke(ctx)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/click/core.py", line 893, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/click/core.py", line 744, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/click/core.py", line 388, in invoke
    return callback(*args, **kwargs)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/stellar/command.py", line 42, in snapshot
    app = Stellar()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/stellar/app.py", line 43, in __init__
    self.init_database()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/stellar/app.py", line 61, in init_database
    tables_missing = self.create_stellar_database()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/stellar/app.py", line 70, in create_stellar_database
    self.operations.create_database('stellar_data')
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/stellar/operations.py", line 31, in create_database
    '%s%s' % (raw_conn.engine.url, database)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy_utils/functions/database.py", line 215, in create_database
    engine.execute(text)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1752, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 721, in execute
    return self._execute_text(object, multiparams, params)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 870, in _execute_text
    statement, parameters
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 958, in _execute_context
    context)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1160, in _handle_dbapi_exception
    exc_info
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 951, in _execute_context
    context)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 436, in do_execute
    cursor.execute(statement, parameters)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/cursors.py", line 132, in execute
    result = self._query(query)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/cursors.py", line 271, in _query
    conn.query(q)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/connections.py", line 726, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/connections.py", line 861, in _read_query_result
    result.read()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/connections.py", line 1064, in read
    first_packet = self.connection._read_packet()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/connections.py", line 826, in _read_packet
    packet.check_error()
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/connections.py", line 370, in check_error
    raise_mysql_exception(self._data)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/err.py", line 116, in raise_mysql_exception
    _check_mysql_exception(errinfo)
  File "/Users/brento/.virtualenvs/my-project/lib/python2.7/site-packages/pymysql/err.py", line 109, in _check_mysql_exception
    raise errorclass(errno,errorvalue)
sqlalchemy.exc.OperationalError: (OperationalError) (1044, u"Access denied for user 'my_db_username'@'localhost' to database 'stellar_data'") "CREATE DATABASE stellar_data CHARACTER SET = 'utf8'" ()
phaer commented 10 years ago

sqlalchemy.exc.OperationalError: (OperationalError) (1044, u"Access denied for user 'my_db_username'@'localhost' to database 'stellar_data'") "CREATE DATABASE stellar_data CHARACTER SET = 'utf8'" ()

Are you sure your user has the right privileges to create a new databse? Something like

GRANT CREATE ON stellar_data TO 'my_db_username'@'localhost';

should help.

epicserve commented 10 years ago

I gave the user all global privilages and now I'm getting.

sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1146, u"Table 'stellar_data.snapshot' doesn't exist") 'SELECT count(*) AS count_1 \nFROM (SELECT snapshot.id AS snapshot_id, snapshot.snapshot_name AS snapshot_snapshot_name, snapshot.project_name AS snapshot_project_name, snapshot.hash AS snapshot_hash, snapshot.created_at AS snapshot_created_at, snapshot.worker_pid AS snapshot_worker_pid \nFROM snapshot \nWHERE snapshot.snapshot_name = %s AND snapshot.project_name = %s) AS anon_1' ('snap1', 'my_db_name')
kevinjqiu commented 10 years ago

You may want to drop stellar_data and re initialize.

epicserve commented 10 years ago

That worked. It might be helpful to include what permissions are needed to the readme. Also it might help to know how to add password. I had to do some Google to find the syntax.

Teemu commented 9 years ago

This was added to the README.