Symfony with FOSUserBundle error while updating schema - php

I follow this topic http://symfony.com/doc/current/bundles/FOSUserBundle/index.html
I made steps 1-6 but when I must update database schema.
$ php bin/console doctrine:schema:update --force
I get awful error.
[Doctrine\DBAL\Exception\DriverException]
An exception occurred while executing 'CREATE TABLE fos_user (id INT AUTO_I
NCREMENT NOT NULL, username VARCHAR(255) NOT NULL, username_canonical VARCH
AR(255) NOT NULL, email VARCHAR(255) NOT NULL, email_canonical VARCHAR(255)
NOT NULL, enabled TINYINT(1) NOT NULL, salt VARCHAR(255) NOT NULL, passwor
d VARCHAR(255) NOT NULL, last_login DATETIME DEFAULT NULL, locked TINYINT(1
) NOT NULL, expired TINYINT(1) NOT NULL, expires_at DATETIME DEFAULT NULL,
confirmation_token VARCHAR(255) DEFAULT NULL, password_requested_at DATETIM
E DEFAULT NULL, roles LONGTEXT NOT NULL COMMENT '(DC2Type:array)', credenti
als_expired TINYINT(1) NOT NULL, credentials_expire_at DATETIME DEFAULT NUL
L, UNIQUE INDEX UNIQ_957A647992FC23A8 (username_canonical), UNIQUE INDEX UN
IQ_957A6479A0D96FBF (email_canonical), PRIMARY KEY(id)) DEFAULT CHARACTER S
ET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB':
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t
oo long; max key length is 767 bytes
with error:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t
oo long; max key length is 767 bytes
I don't have idea how to fix it. Anyone can help?
Btw. I am using Symfony 3!

Replace
username_canonical VARCHAR(255) NOT NULL
with
username_canonical VARCHAR(191) NOT NULL
and do the same with email_canonical
if you use Doctrine ORM entity you must set:
/**
* #ORM\Column(type="string", unique=true, length=191)
*/
private $usernameCanonical;
take a look into length=191

Related

The phpMyAdmin configuration storage is not completely configured, some extended - Xammp - Version -7.3.8-0-VC15

I updated Xampp version - Latest version = 7.3.8-0-VC15
I am getting these errors -
Error 1-
The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why.
I clicked on to find out why but did not understand that -
Error 2 -
mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'#'localhost' (using password: NO)
Error 3-
Connection for controluser as defined in your configuration failed.
I tried many solutions but not solved.
It's a mistake for missing some defaults table for default phpmydamin database. For solve this mistake you must to run following queries in phpmyadmin database
I suggest you download and install JetBrains DataGrip and connect this software with your local database and run following query on it to fixing phpmyadmin problem. another way is if you are friendly with command line log in to mysql with command line and run queries.
CREATE TABLE IF NOT EXISTS `pma_users` (
`username` varchar(64) NOT NULL,
`usergroup` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`usergroup`)
)
COMMENT='Users and their assignments to user groups'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS `pma_usergroups` (
`usergroup` varchar(64) NOT NULL,
`tab` varchar(64) NOT NULL,
`allowed` enum('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`usergroup`,`tab`,`allowed`)
)
COMMENT='User groups with configured menu items'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE IF NOT EXISTS `pma_navigationhiding` (
`username` varchar(64) NOT NULL,
`item_name` varchar(64) NOT NULL,
`item_type` varchar(64) NOT NULL,
`db_name` varchar(64) NOT NULL,
`table_name` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`item_name`,`item_type`,`db_name`,`table_name`)
)
COMMENT='Hidden items of navigation tree'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
Then add following code to config.inc.php file:
$cfg['Servers'][$i]['users'] = 'pma_users';
$cfg['Servers'][$i]['usergroups'] = 'pma_usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma_navigationhiding';

VBulletin 5.4.0 installation Error: 1071

Today I Was Installing Vbulletin For The First Time And During The Installation, It Gave This Error.
Creating userchangelog table An error has occurred with your database.
Please contact vBulletin Support for assistance.
Module: install, Step 3 Database Error:1071
Specified key was too long; max key length is 1000 bytes
Query:
CREATE TABLE userchangelog ( changeid INT UNSIGNED NOT NULL
AUTO_INCREMENT, userid INT UNSIGNED NOT NULL DEFAULT '0', fieldname
VARCHAR(250) NOT NULL DEFAULT '', newvalue VARCHAR(250) NOT NULL
DEFAULT '', oldvalue VARCHAR(250) NOT NULL DEFAULT '', adminid INT
UNSIGNED NOT NULL DEFAULT '0', change_time INT UNSIGNED NOT NULL
DEFAULT '0', change_uniq VARCHAR(32) NOT NULL DEFAULT '', ipaddress
INT UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (changeid), KEY
userid (userid,change_time), KEY change_time (change_time), KEY
change_uniq (change_uniq), KEY fieldname (fieldname,change_time),
KEY adminid (adminid,change_time) ) ENGINE = MyISAM Status: Aborted
Version VBulletin: 5.4.0 PHP: 7.0 MYSQL: I Have No Idea!
Before The Installation, I Run A Script Called vb_test.php The Result Said That VBulletin 5.4.0 Can Run On This Server Without Any Error
From the failed error, it seems that you are using MyISAM engine. Better to change the default storage engine of the mysql server to Innodb and also set the innodb_large_prefix to ON.
To set the default storage engine and to enable innodb_large_prefix, you can add the below line in my.cnf
default_storage_engine = innodb
innodb_large_prefix = ON
After this, try to install and see if it works.

Error Importing MySQL with JSON Data as column

I have an error while I am importing a db structure in MySQL
Error:
[ERROR in query 14] You have an error in your SQL syntax; check the
manual that corresponds to your MariaDB server version for the right
syntax to use near 'json DEFAULT NULL, account_name char(255)
DEFAULT NULL, account_user_id ' at line 3 Import cancelled!
The whole exact SQL command is as follows:
CREATE TABLE ees_account ( account_business_id int(32) NOT NULL
AUTO_INCREMENT, data json DEFAULT NULL, account_name char(255)
DEFAULT NULL, account_user_id int(32) DEFAULT '0', created_at
timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT
NULL, account_status int(32) DEFAULT '1', account_description
text, account_website char(255) DEFAULT NULL, account_address
char(255) DEFAULT NULL, account_email char(255) DEFAULT NULL,
account_country_id int(32) DEFAULT NULL, business_reference_id
char(255) DEFAULT NULL, account_client_logo text,
client_reference_id char(255) DEFAULT NULL, PRIMARY KEY
(account_business_id) ) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT
CHARSET=utf8;
Any idea what could be the potential cause ? I check the MySQL version which is same i.e. 5.7.17
Faced a similar issue few months back and the issues was MySQL version. MariaDB 10.2 supported JSON. (Alpha version. Not recommended by Maria to production server. Only testing.)MariaDB 10.1 do not support JSON.
So if you have WAMP or XAMPP dev stack then most probably you have 10.1.16-MariaDB which doesn't support JSON. So upgrade your MySQL and it will be resolved.

Joomla Database import does not work

i made a backup of my joomla MySQL database using the export function of phpMyAdmin.
When i try to import this backup file, it gives me a lot of errors like "You have an error in your SQL syntax..." even if the SQL looks quite correct.
Here is a small part of the backup, which doesnt even work:
CREATE TABLE `jos_assets` (
`id` int(10) UNSIGNED NOT NULL COMMENT 'Primary Key',
`parent_id` int(11) NOT NULL DEFAULT '0'COMMENT AS `Nested set parent.`,
`lft` int(11) NOT NULL DEFAULT '0'COMMENT AS `Nested set lft.`,
`rgt` int(11) NOT NULL DEFAULT '0'COMMENT AS `Nested set rgt.`,
`level` int(10) UNSIGNED NOT NULL COMMENT 'The cached level in the nested tree.',
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The unique name for the asset.\n',
`title` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'The descriptive title for the asset.',
`rules` varchar(5120) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'JSON encoded access control.'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
When i run this command, i get the following error message:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS `Nested set parent.`,
`lft` int(11) NOT NULL DEFAULT '0'COMMENT AS `Nested ' at line 3
Can someone explain to me what is wrong here? This code was automatically generated by phpMyAdmin and it looks like valid SQL to me!
Im using:
phpMyAdmin version 4.5.5
PHP version 5.6.14
Server version 10.0.23-MariaDB-0+deb8u1
Joomla version 3.5.0
Ok guys i found out the problem myself:
It seems the line
COMMENT AS `Nested set parent.`,
is no valid SQL. Correct would be
COMMENT 'Nested set parent.',
like you can see in the other lines.
I dont know why phpMyAdmin creates a MySQL Dump with invalid SQL, but this caused the problem.

What's wrong with this PHP-MySQL CREATE TABLE query?

First, I'm just starting to learn MySQL with PHP.
My query copy/paste directly from my IDE:
$query = "CREATE TABLE IF NOT EXISTS $table_messages (
id int(11) unsigned NOT NULL auto_increment,
show tinyint(1) unsigned NOT NULL default '0',
to varchar(255) NOT NULL default '',
from varchar(255) NOT NULL default '',
type varchar(255) NOT NULL default '',
message varchar(255) NOT NULL default '',
PRIMARY KEY(id)
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
$result = mysql_query( $query, $link ) OR exit ( mysql_error() );
Results in this error:
You have an error in your SQL syntax;
near 'show tinyint(1) unsigned NOT
NULL default '0' , to varchar(255) N'
at line 4
... so I add one character to show (e.g. showz) and get this error:
You have an error in your SQL syntax;
near 'to varchar(255) NOT NULL
default '' , from varchar(255) NOT
NUL' at line 5
... so I add one character to to (e.g. toz) and get this error:
You have an error in your SQL syntax;
near 'from varchar(255) NOT NULL
default '' , type varchar(255) NOT NU'
at line 6
... so I add one character to from (e.g. fromz) and IT WORKS!?
What is going on? Lol
If this question is too blatantly obvious, I'll remove it if the community thinks it would be prudent, but in the meantime I'm stumped.
BTW, I've messed with spacing, case and other things without any success.
SHOW, TO and FROM are reserved MySQL keywords. You must quote them with backticks to make them work as column names:
$query = "CREATE TABLE IF NOT EXISTS $table_messages (
`id` int(11) unsigned NOT NULL auto_increment,
`show` tinyint(1) unsigned NOT NULL default '0' ,
`to` varchar(255) NOT NULL default '' ,
`from` varchar(255) NOT NULL default '' ,
`type` varchar(255) NOT NULL default '' ,
`message` varchar(255) NOT NULL default '' ,
PRIMARY KEY(id)
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
It's usually good practice (though unneeded) to quote every column name this way to prevent accidental collisions with keywords as there are hundreds of them. For a full list, see http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html.
You might be interested in this list of reserved words in MySQL statements. In short, if you want to use any of these as a column name (or anywhere in following queries), you have to quote them, usually in backticks:
`show` TINYINT(1) UNSIGNED NOT NULL,
...and later:
SELECT `show` FROM `varchar` WHERE `to`="France"
Just a stab in the dark, but are to and from reserved words in mysql? Could you either wrap those words in [] like [to] and [from] or, like you did, change the terms to toperson or fromperson?
This is not the answer to your problem, but it's the answer to "What's wrong with a PHP-MySQL CREATE TABLE query?" (for another googler)
Maybe not all versions of PHP are like this, but in my environment, non PDO commands like "mysql_query" throws an error when I try to make a table:
CREATE TABLE IF NOT EXISTS `actionlog`
Error:
You have an error in your SQL syntax
Works just fine with the PDO adapter.

Categories