sw-cli-tools
sw-cli-tools copied to clipboard
SQL Permissions checking seems to be broken
Command I ran:
sudo -H -u www-data /var/www/bin/sw.phar install:release --no-interaction --release 5.5.4 --install-dir /var/www/shopware.example.org/htdocs --shop-host shopware.example.org --db-host 10.128.3.16 --db-port 3306 --db-user shopware --db-password kjahdkjhagsjdhasd --db-name shopware
Output:
Downloading release
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///var/www/bin/sw.phar/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 67
Unzipping archive
Creating database shopware
Writing config.php
[RuntimeException]
Your user has not enough privileges for database "shopware" the ALTER privilege is required
install [--db-host="..."] [--db-port="..."] [--db-socket="..."] [--db-user="..."] [--db-password="..."] [--db-name="..."] [--no-skip-import] [--shop-locale="..."] [--shop-host="..."] [--shop-path="..."] [--shop-name="..."] [--shop-email="..."] [--shop-currency="..."] [--skip-admin-creation] [--admin-username="..."] [--admin-password="..."] [--admin-email="..."] [--admin-locale="..."] [--admin-name="..."]
[RuntimeException]
Command failed. Error Output:
[RuntimeException]
Your user has not enough privileges for database "shopware" the ALTER privilege is required
install [--db-host="..."] [--db-port="..."] [--db-socket="..."] [--db-user="..."] [--db-password="..."] [--db-name="..."] [--no-skip-import] [--shop-locale="..."] [--shop-host="..."] [--shop-path="..."] [--shop-name="..."] [--shop-email="..."] [--shop-currency="..."] [--skip-admin-creation] [--admin-username="..."] [--admin-password="..."] [--admin-email=".
.."] [--admin-locale="..."] [--admin-name="..."]
install:release [-r|--release RELEASE] [-i|--install-dir INSTALL-DIR] [--unpack-only] [--skip-download] [--db-host DB-HOST] [--db-port DB-PORT] [--db-socket DB-SOCKET] [--db-user DB-USER] [--db-password DB-PASSWORD] [--db-name DB-NAME] [--no-skip-import] [--shop-locale SHOP-LOCALE] [--shop-host SHOP-HOST] [-p|--shop-path SHOP-PATH] [--shop-name SHOP-NAME] [--shop-email SHOP-EMAIL] [--shop-currency SHOP-CURRENCY] [--skip-admin-creation] [--admin-username ADMIN-USERNAME] [--admin-password ADMIN-PASSWORD] [--admin-email ADMIN-EMAIL] [--admin-locale ADMIN-LOCALE] [--admin-name ADMIN-NAME]
But permissions should be enough:
root@mbaur:/var/log/mysql# pt-show-grants | grep shopware
-- Grants for 'shopware'@'10.128.3.%'
CREATE USER IF NOT EXISTS 'shopware'@'10.128.3.%';
ALTER USER 'shopware'@'10.128.3.%' IDENTIFIED WITH 'mysql_native_password' AS '*lkjahdkjhajkdhaskldjhaskljdhajdhaskld.hasd' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK;
GRANT ALL PRIVILEGES ON `shopware`.* TO 'shopware'@'10.128.3.%';
GRANT USAGE ON *.* TO 'shopware'@'10.128.3.%';
Ah I think I now get it. You're trying to change the database collation/char set:
$docroot/recovery/install/src/Service/DatabaseService.php
return $this->connection->exec(
sprintf(
'%s DATABASE `%s` CHARACTER SET `%s` COLLATE `%s`',
$dbExists ? 'ALTER' : 'CREATE',
$name,
$charset,
$collation
)
);
Which is fine, but could you please check if that is already correct?
root@mbaur:/var/log/mysql# mysql -e 'show create database shopware'
+----------+-------------------------------------------------------------------------------------------+
| Database | Create Database |
+----------+-------------------------------------------------------------------------------------------+
| shopware | CREATE DATABASE `shopware` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */ |
+----------+-------------------------------------------------------------------------------------------+
Also, the following SQL breaks for a use configured like 'shopware'@'10.128.3.%':
$docroot/recovery/install/src/Service/DatabaseService.php
$sql = <<<'EOL'
SELECT PRIVILEGE_TYPE, REPLACE(GRANTEE,"'","") AS _grantee
FROM information_schema.SCHEMA_PRIVILEGES
WHERE PRIVILEGE_TYPE=:priv AND TABLE_SCHEMA=:name
HAVING _grantee = USER()
OR _grantee=CONCAT(SUBSTRING_INDEX(USER(),'@',1),'@%')
EOL;