Step 2: Install MySQL and create the necessary databases and users

Nova and glance will use MySQL to store their runtime data. To make sure they can do that, we'll install and set up MySQL. Do this:

apt-get install -y mysql-server python-mysqldb

When the package installation is done and you want other machines (read: OpenStack computing nodes) to be able to talk to that MySQL database, too, open up /etc/mysql/my.cnf in your favourite editor and change this line:

bind-address = 127.0.0.1

to look like this:

bind-address = 0.0.0.0

Then, restart MySQL:

service mysql restart

Now create the user accounts in mysql and grant them access on the according databases, which you need to create, too: 

mysql -u root <<EOF
CREATE DATABASE nova;
GRANT ALL PRIVILEGES ON nova.* TO 'novadbadmin'@'%' 
  IDENTIFIED BY 'dieD9Mie';
EOF
mysql -u root <<EOF
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glancedbadmin'@'%' 
  IDENTIFIED BY 'ohC3teiv';
EOF
mysql -u root <<EOF
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystonedbadmin'@'%'
  IDENTIFIED BY 'Ue0Ud7ra';
EOF

Please note: In this example setup, the MySQL database does not have a password for root set. This is bad practice and should not happen in everyday's business. If you have a password set for the MySQL root user, supply it to the above MySQL commands by adding the -p parameter after "-u root". 

Comments

Access denied for user 'keystonedbadmin'@'

If someone follows the script he will get:

root@controller:~# keystone-manage db_syncTraceback (most recent call last):  File "/usr/bin/keystone-manage", line 28, in <module>    cli.main(argv=sys.argv, config_files=config_files)  File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 148, in main    return run(cmd, (args[:1] + args[2:]))  File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 134, in run    return CMDS[cmd](argv=args).run()  File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 36, in run    return self.main()  File "/usr/lib/python2.7/dist-packages/keystone/cli.py", line 57, in main    driver.db_sync()  File "/usr/lib/python2.7/dist-packages/keystone/identity/backends/sql.py", line 135, in db_sync    migration.db_sync()  File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration.py", line 50, in db_sync    current_version = db_version()  File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration.py", line 66, in db_version    return db_version_control(0)  File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration.py", line 72, in db_version_control    CONF.sql.connection, repo_path, version)  File "<string>", line 2, in version_control  File "/usr/lib/python2.7/dist-packages/migrate/versioning/util/__init__.py", line 159, in with_engine    return f(*a, **kw)  File "/usr/lib/python2.7/dist-packages/migrate/versioning/api.py", line 250, in version_control    ControlledSchema.create(engine, repository, version)  File "/usr/lib/python2.7/dist-packages/migrate/versioning/schema.py", line 139, in create    table = cls._create_table_version(engine, repository, version)  File "/usr/lib/python2.7/dist-packages/migrate/versioning/schema.py", line 180, in _create_table_version    if not table.exists():  File "/usr/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 549, in exists    self.name, schema=self.schema)  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2274, in run_callable    conn = self.contextual_connect()  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2340, in contextual_connect    self.pool.connect(),   File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 210, in connect    return _ConnectionFairy(self).checkout()  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 371, in __init__    rec = self._connection_record = pool._do_get()  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 697, in _do_get    con = self._create_connection()  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 174, in _create_connection    return _ConnectionRecord(self)  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 256, in __init__    self.connection = self.__connect()  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 316, in __connect    connection = self.__pool._creator()  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 80, in connect    return dialect.connect(*cargs, **cparams)  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 280, in connect    return self.dbapi.connect(*cargs, **cparams)  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect    return Connection(*args, **kwargs)  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__    super(Connection, self).__init__(*args, **kwargs2)sqlalchemy.exc.OperationalError: (OperationalError) (1045, "Access denied for user 'keystonedbadmin'@'controller' (using password: YES)") None None

When did you check this guide last time? It looks that there are several issues with ubuntu updates.

Access denied for user 'keystonedbadmin'@'controller'

Hi ipprofis.

I had the same problem like you.

I solved it with the following two mysql lines :

mysql> CREATE USER 'keystonedbadmin'@'localhost' IDENTIFIED BY 'Ue0Ud7ra';

mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystonedbadmin'@'localhost' WITH GRANT OPTION;

you can read about adding user accounts from here : http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

The newer versions of mysql

The newer versions of mysql require you to set the login for both the % and localhost.

It does not work for me.

I get an error message:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

To get around this, I have to add the -p option, so that it explicitly ask me for a password.

Possibly, it would not ask me for a password if I hadn't set one up in the MySQL installation, but in that case you should specify explicitly to leave the password blank, because that is a "bad practice".

Re: It does not work for me.

Hello,

thanks for the suggestion; we know about the MySQL password thing and we were wondering whether to include the -p option or not; we did decide not to include it because those having a password set will most probably know about it anyway ;-)

How to solve this !

Hello There !

 

I have solved this problem by adding -p<passwrod> without spaces, like example below, where 12345 is my passwrod:

mysql -u root -p12345 <<EOF
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystonedbadmin'@'%'
  IDENTIFIED BY 'Ue0Ud7ra';

reset mysql password

If you need to reset the password, the following works.

From:  http://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/

sudo /etc/init.d/mysql stop

sudo mysqld --skip-grant-tables &

mysql -u root mysql

UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;