SQL access denied which nova-manage db sync

Asked by fred yang on 2011-05-20

I am installing nova from source code on ubuntu 10.10. If following
$ mysql -uroot -ppassword
> CREATE DATABASE nova;
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
> SET PASSWORD FOR 'root'@'%' = PASSWORD('nova');
to grant password to nova, and specify "--sql_connection=mysql://root:nova@192.168.0.13/nova" in bin/nova.conf, then I will get Access denied while running nova-manage db sync.

But if I change to 'root'@localhost in Mysql and root://root:nova@localhost/nova in conf, then db sync works fine.
It seems no others has this issue, can you share your fixes?
Thanks,
-Fred

Error log attached

2011-05-19 22:22:08,200 DEBUG migrate.versioning.util [-] Disposing SQLAlchemy engine Engine(mysql://root:nova@192.168.0.13/nova) from (pid=2269) with_engine /usr/lib/pymodules/python2.6/migrate/versioning/util/__init__.py:163
Command failed, please check log for more info
2011-05-19 22:22:08,205 CRITICAL nova [-] (OperationalError) (1045, "Access denied for user 'root'@'story' (using password: YES)") None None
(nova): TRACE: Traceback (most recent call last):
(nova): TRACE: File "./bin/nova-manage", line 1142, in <module>
(nova): TRACE: main()
(nova): TRACE: File "./bin/nova-manage", line 1131, in main
(nova): TRACE: fn(*argv)
(nova): TRACE: File "./bin/nova-manage", line 755, in sync
(nova): TRACE: return migration.db_sync(version)
(nova): TRACE: File "/home/fred/o1/nova/nova/db/migration.py", line 35, in db_sync
(nova): TRACE: return IMPL.db_sync(version=version)
(nova): TRACE: File "/home/fred/o1/nova/nova/db/sqlalchemy/migration.py", line 41, in db_sync
(nova): TRACE: db_version()
(nova): TRACE: File "/home/fred/o1/nova/nova/db/sqlalchemy/migration.py", line 56, in db_version
(nova): TRACE: meta.reflect(bind=engine)
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/schema.py", line 1925, in reflect
(nova): TRACE: conn = bind.contextual_connect()
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/engine/base.py", line 1742, in contextual_connect
(nova): TRACE: self.pool.connect(),
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 158, in connect
(nova): TRACE: return _ConnectionFairy(self).checkout()
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 329, in __init__
(nova): TRACE: rec = self._connection_record = pool.get()
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 177, in get
(nova): TRACE: return self.do_get()
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 692, in do_get
(nova): TRACE: con = self.create_connection()
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 138, in create_connection
(nova): TRACE: return _ConnectionRecord(self)
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 213, in __init__
(nova): TRACE: self.connection = self.__connect()
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 279, in __connect
(nova): TRACE: connection = self.__pool._creator()
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/engine/strategies.py", line 76, in connect
(nova): TRACE: return dialect.connect(*cargs, **cparams)
(nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/engine/default.py", line 238, in connect
(nova): TRACE: return self.dbapi.connect(*cargs, **cparams)
(nova): TRACE: File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in Connect
(nova): TRACE: return Connection(*args, **kwargs)
(nova): TRACE: File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in __init__
(nova): TRACE: super(Connection, self).__init__(*args, **kwargs2)
(nova): TRACE: OperationalError: (OperationalError) (1045, "Access denied for user 'root'@'story' (using password: YES)") None None
(nova): TRACE:

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
Vish Ishaya
Solved:
Last query:
Last reply:
Best Vish Ishaya (vishvananda) said : #1

You probably have an entry for root@'story' in your user records.
I've had bad luck using SET PASSWORD, it doesn't always seem to change all of the user records. Try an update instead:

mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
    -> WHERE User='root';
mysql> FLUSH PRIVILEGES;

Vish

On May 19, 2011, at 10:35 PM, fred yang wrote:

> New question #158294 on OpenStack Compute (nova):
> https://answers.launchpad.net/nova/+question/158294
>
> I am installing nova from source code on ubuntu 10.10. If following
> $ mysql -uroot -ppassword
>> CREATE DATABASE nova;
>> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
>> SET PASSWORD FOR 'root'@'%' = PASSWORD('nova');
> to grant password to nova, and specify "--sql_connection=mysql://root:nova@192.168.0.13/nova" in bin/nova.conf, then I will get Access denied while running nova-manage db sync.
>
> But if I change to 'root'@localhost in Mysql and root://root:nova@localhost/nova in conf, then db sync works fine.
> It seems no others has this issue, can you share your fixes?
> Thanks,
> -Fred
>
> Error log attached
>
> 2011-05-19 22:22:08,200 DEBUG migrate.versioning.util [-] Disposing SQLAlchemy engine Engine(mysql://root:nova@192.168.0.13/nova) from (pid=2269) with_engine /usr/lib/pymodules/python2.6/migrate/versioning/util/__init__.py:163
> Command failed, please check log for more info
> 2011-05-19 22:22:08,205 CRITICAL nova [-] (OperationalError) (1045, "Access denied for user 'root'@'story' (using password: YES)") None None
> (nova): TRACE: Traceback (most recent call last):
> (nova): TRACE: File "./bin/nova-manage", line 1142, in <module>
> (nova): TRACE: main()
> (nova): TRACE: File "./bin/nova-manage", line 1131, in main
> (nova): TRACE: fn(*argv)
> (nova): TRACE: File "./bin/nova-manage", line 755, in sync
> (nova): TRACE: return migration.db_sync(version)
> (nova): TRACE: File "/home/fred/o1/nova/nova/db/migration.py", line 35, in db_sync
> (nova): TRACE: return IMPL.db_sync(version=version)
> (nova): TRACE: File "/home/fred/o1/nova/nova/db/sqlalchemy/migration.py", line 41, in db_sync
> (nova): TRACE: db_version()
> (nova): TRACE: File "/home/fred/o1/nova/nova/db/sqlalchemy/migration.py", line 56, in db_version
> (nova): TRACE: meta.reflect(bind=engine)
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/schema.py", line 1925, in reflect
> (nova): TRACE: conn = bind.contextual_connect()
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/engine/base.py", line 1742, in contextual_connect
> (nova): TRACE: self.pool.connect(),
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 158, in connect
> (nova): TRACE: return _ConnectionFairy(self).checkout()
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 329, in __init__
> (nova): TRACE: rec = self._connection_record = pool.get()
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 177, in get
> (nova): TRACE: return self.do_get()
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 692, in do_get
> (nova): TRACE: con = self.create_connection()
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 138, in create_connection
> (nova): TRACE: return _ConnectionRecord(self)
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 213, in __init__
> (nova): TRACE: self.connection = self.__connect()
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line 279, in __connect
> (nova): TRACE: connection = self.__pool._creator()
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/engine/strategies.py", line 76, in connect
> (nova): TRACE: return dialect.connect(*cargs, **cparams)
> (nova): TRACE: File "/usr/lib/python2.6/dist-packages/sqlalchemy/engine/default.py", line 238, in connect
> (nova): TRACE: return self.dbapi.connect(*cargs, **cparams)
> (nova): TRACE: File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in Connect
> (nova): TRACE: return Connection(*args, **kwargs)
> (nova): TRACE: File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in __init__
> (nova): TRACE: super(Connection, self).__init__(*args, **kwargs2)
> (nova): TRACE: OperationalError: (OperationalError) (1045, "Access denied for user 'root'@'story' (using password: YES)") None None
> (nova): TRACE:
>
>
> --
> You received this question notification because you are a member of Nova
> Core, which is an answer contact for OpenStack Compute (nova).

Execute the following command before do nova-mange db sync.

sudo sed -i "s/127.0.0.1/0.0.0.0/g" /etc/mysql/my.cnf

fred yang (fred-yang) said : #3

Thanks Vish Ishaya, that solved my question.