kiranchavala opened a new issue, #11912:
URL: https://github.com/apache/cloudstack/issues/11912

   ### problem
   
   Getting an exception when I run the command 
   
   cloudstack-setup-databases cloud:password@localhost -s -u -v
   
   ### versions
   
   ACS 4.21, ubuntu 22.04 
   
   ### The steps to reproduce the bug
   
   
   
   1. Install mysql server 
   
   apt-get install mysql-server
   
   2. Set a root password
   
   ```
   
   mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 
'password';
   mysql>FLUSH PRIVILEGES;
   
   ```
   
   3. Configure InnoDB settings in mysql server’s 
/etc/mysql/mysql.conf.d/mysqld.cnf:
   
   ```
   
   [mysqld]
   
   server_id = 1
   
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION"
   innodb_rollback_on_timeout=1
   innodb_lock_wait_timeout=600
   max_connections=1000
   log-bin=mysql-bin
   binlog-format = 'ROW'
   
   ```
   
   
   4. systemctl restart mysql
   
   5. Log in with root password and execute the following commands
   
   mysql -u root -p 
   
   ```
   -- Create the cloud and cloud_usage databases
   CREATE DATABASE `cloud`;
   CREATE DATABASE `cloud_usage`;
   
   -- Create the cloud user
   CREATE USER cloud@`localhost` identified by 'password';
   CREATE USER cloud@`%` identified by 'password';
   
   -- Grant all privileges to the cloud user on the databases
   GRANT ALL ON cloud.* to cloud@`localhost`;
   GRANT ALL ON cloud.* to cloud@`%`;
   
   GRANT ALL ON cloud_usage.* to cloud@`localhost`;
   GRANT ALL ON cloud_usage.* to cloud@`%`;
   
   -- Grant process list privilege for all other databases
   GRANT process ON *.* TO cloud@`localhost`;
   GRANT process ON *.* TO cloud@`%`;
   
   ```
   
   6. Check the settings
   
   ```
   
   mysql> SHOW GRANTS FOR 'cloud'@'localhost';
   +----------------------------------------------------------------+
   | Grants for cloud@localhost                                     |
   +----------------------------------------------------------------+
   | GRANT PROCESS ON *.* TO `cloud`@`localhost`                    |
   | GRANT ALL PRIVILEGES ON `cloud`.* TO `cloud`@`localhost`       |
   | GRANT ALL PRIVILEGES ON `cloud_usage`.* TO `cloud`@`localhost` |
   +----------------------------------------------------------------+
   3 rows in set (0.00 sec)
   
   mysql> SHOW GRANTS FOR 'cloud'@'%';
   +--------------------------------------------------------+
   | Grants for cloud@%                                     |
   +--------------------------------------------------------+
   | GRANT PROCESS ON *.* TO `cloud`@`%`                    |
   | GRANT ALL PRIVILEGES ON `cloud`.* TO `cloud`@`%`       |
   | GRANT ALL PRIVILEGES ON `cloud_usage`.* TO `cloud`@`%` |
   +--------------------------------------------------------+
   3 rows in set (0.00 sec)
   
   mysql> SELECT user, host FROM mysql.user WHERE user='cloud';
   +-------+-----------+
   | user  | host      |
   +-------+-----------+
   | cloud | %         |
   | cloud | localhost |
   +-------+-----------+
   2 rows in set (0.00 sec)
   
   ```
   
   7.  Deploy the schema 
   
   
   
   
   ```
   root@test-cs-installation:~# cloudstack-setup-databases 
cloud:password@localhost -s -u -v
   Mysql user name:cloud                                                        
   [ OK ]
   Mysql user password:******                                                   
   [ OK ]
   Mysql server ip:localhost                                                    
   [ OK ]
   Mysql server port:3306                                                       
   [ OK ]
   Checking Cloud database files ...                                            
   [ OK ]
   Checking local machine hostname ...                                          
   [ OK ]
   Checking SELinux setup ...                                                   
   [ OK ]
   Detected local IP address as 127.0.1.1, will use as cluster management 
server node IP[ OK ]
   Preparing /etc/cloudstack/management/db.properties                           
   [ OK ]
   
   
   We apologize for below error:
   ***************************************************************
   Aborting script as the databases (cloud, cloud_usage) already exist.
   Please use the --force-recreate parameter if you want to recreate the 
schemas.
   ***************************************************************
   Please run:
   
       cloudstack-setup-databases -h
   
   for full help
   
   ```
   
   
   
   
   A workaround is to use the parameter force
   
   ```
   root@test-cs-installation:~# cloudstack-setup-databases 
cloud:password@localhost -s -u -v --force-recreate
   Mysql user name:cloud                                                        
   [ OK ]
   Mysql user password:******                                                   
   [ OK ]
   Mysql server ip:localhost                                                    
   [ OK ]
   Mysql server port:3306                                                       
   [ OK ]
   Checking Cloud database files ...                                            
   [ OK ]
   Checking local machine hostname ...                                          
   [ OK ]
   Checking SELinux setup ...                                                   
   [ OK ]
   Detected local IP address as 127.0.1.1, will use as cluster management 
server node IP[ OK ]
   Preparing /etc/cloudstack/management/db.properties                           
   [ OK ]
   Applying /usr/share/cloudstack-management/setup/create-schema.sql            
   [ OK ]
   Applying /usr/share/cloudstack-management/setup/create-schema-premium.sql    
   [ OK ]
   Applying /usr/share/cloudstack-management/setup/server-setup.sql             
   [ OK ]
   Applying /usr/share/cloudstack-management/setup/templates.sql                
   [ OK ]
   Processing encryption ...                                                    
   [ OK ]
   Finalizing setup ...                                                         
   [ OK ]
   
   CloudStack has successfully initialized database, you can check your 
database configuration in /etc/cloudstack/management/db.properties
   
   ````
   
   
   ### What to do about it?
   
   The command should without --force-recreate option 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to