Last issue with MySQL is solved by renaming all tables and adding a prefix. There is a table "groups" which is a reserved word and it causes sql query to crash.
Below are queries that I used and I will post them here in case someone else encounters same issues.
To generate sql query that will rename all tables in selected database you can use query below:To add primary key to phpbb columns that do not have it you can use following query (solves issue with DIgital Ocean requirement that all tables must have primary key):
To get list of tables without primary key you can use this query:
At the moment tables without primary keys are following ones:
Below are queries that I used and I will post them here in case someone else encounters same issues.
To generate sql query that will rename all tables in selected database you can use query below:
Code:
SET group_concat_max_len = 6144;SELECT CONCAT('RENAME TABLE ', GROUP_CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '` TO `', TABLE_SCHEMA, '`.`prefix_', TABLE_NAME, '`')) AS qFROM `information_schema`.`Tables` WHERE TABLE_SCHEMA='db name';
Code:
ALTER TABLE phpbb.password_resets ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.acl_groups ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.acl_users ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.captcha_answers ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.ext ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.forums_watch ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.login_attempts ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.moderator_cache ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.oauth_states ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.oauth_tokens ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.poll_options ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.poll_votes ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.privmsgs_to ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.search_wordmatch ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.topics_watch ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.user_group ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;ALTER TABLE phpbb.user_notifications ADD COLUMN `my_id` int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT;
To get list of tables without primary key you can use this query:
Code:
SELECT tab.table_schema AS database_name, tab.table_name AS table_name, tab.table_rows AS table_rows FROM information_schema.tables tab LEFT JOIN information_schema.table_constraints tco ON (tab.table_schema = tco.table_schema AND tab.table_name = tco.table_name AND tco.constraint_type = 'PRIMARY KEY') WHERE tab.table_schema NOT IN ('mysql', 'information_schema', 'performance_schema', 'sys') AND tco.constraint_type IS NULL AND tab.table_type = 'BASE TABLE';
At the moment tables without primary keys are following ones:
Code:
+---------------+--------------------+------------+| database_name | table_name | table_rows |+---------------+--------------------+------------+| phpbb | acl_groups | 129 || phpbb | acl_users | 10 || phpbb | captcha_answers | 18 || phpbb | ext | 2 || phpbb | forums_watch | 7 || phpbb | login_attempts | 0 || phpbb | moderator_cache | 4 || phpbb | oauth_states | 0 || phpbb | oauth_tokens | 0 || phpbb | poll_options | 19 || phpbb | poll_votes | 52 || phpbb | privmsgs_to | 3296 || phpbb | search_wordmatch | 38746 || phpbb | topics_watch | 1188 || phpbb | user_group | 3158 || phpbb | user_notifications | 12719 |+---------------+--------------------+------------+16 rows in set (0.02 sec)
Statistics: Posted by BlueyeNS — Thu Sep 26, 2024 4:46 pm