Designed Database and Table in Local Server Using MySQL 5.6.17 and Export into *.sql file.
When try to Import *.sql file into Live Server(MySQL 5.1.36) got below Error:
#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
Understood the issue through this link
Is there any way to import Local Server's *.sql file to Live Server without Updating MySQL Version?
TABLE:
CREATE TABLE 'currency' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'currency_name' varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT
NULL,
'country' varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
'currency' varchar(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
'created_by' int(11) NOT NULL,
'created_on' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
'status' int(1) NOT NULL DEFAULT '1',
'modified_by' int(11) DEFAULT NULL,
'modified_on' timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY ('id')) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;
NOTE:- Windows Server Running WAMP(Local Server) and QNAP(Live Server).
There is not a direct way to do it, since this is not a valid table definition for any version prior to MySQL Server 5.6.5.
You could edit the dump file by hand or with a tool like sed or perl to modify the offending lines, or you could change the table definition on the source server... but then your application, which presumably expects this behavior, isn't going to work properly.
You could also modify the table definition to make it valid for 5.1, with only one automatic timestamp, and use triggers to get the rest of the desired behavior.
The best course, of course, is one of these:
update the 5.1 server to 5.5 and then to 5.6, or
when developing for a 5.1 server, always use 5.1 in the development environment, so you don't get into conditions like this, relying on newer features that aren't compatible with older deployments... remembering, though, that there are some pretty significant improvements that happened in version 5.6.
Related
Absolutely cannot get rid of these errors in phpmyadmin Version information: 4.2.11
$cfg['Servers'][$i]['users'] ... not OK [ Documentation ]
$cfg['Servers'][$i]['usergroups'] ... not OK [ Documentation ]
Configurable menus: Disabled
$cfg['Servers'][$i]['navigationhiding'] ... not OK [ Documentation ]
Hide/show navigation items: Disabled
$cfg['Servers'][$i]['savedsearches'] ... not OK [ Documentation ]
Saving Query-By-Example searches: Disabled
I have tried the following:
ran SQL
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 updated my config.inc.php with
$cfg['Servers'][$i]['users'] = 'pma_users';
$cfg['Servers'][$i]['usergroups'] = 'pma_usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma_navigationhiding';
Then flushed table caches and restarted phpMyAdmin. The tables for pma_users and uaergroups have been created, but I still get the errors.
PLEASE HELP! This is causing serious issues with my drupal functionality.
Note, I have not yet set root or pma_user passwords.
Ultimately my solution to this problem was to move away from XAMPP local hosting. I moved my site files to remote server, and installed my database and imported my database to their phpyadmin without any issue. Site is now connecting and working beautifully. Spending countless hours following every post I could find and referring to the phpmyadmin documentation were to no avail as opposed to just abandoning ship and going with potentially a more novice user like myself. This worked for me because the remote hosting option was a viable. Unfortunately this answer is not helpful to those whom still need local hosting environment and are using XAMPP. I have the Aquia Dev Desktop that included XAMPP with great success in the past and maybe good option some.
I've recently started using laravel for a project I'm working on, and I'm currently having problems displaying data from my database in the correct character encoding.
My current system consists of a separate script responsible for populating the database with data, while the laravel project is reponsible for displaying the data. The view that is used, is set to display all text as utf-8, which works as I've successfully printed special characters in the view. Text from the database is not printed as utf8, and will not print special characters the right way. I've tried using both eloquent models and DB::select(), but they both show the same poor result.
charset in database.php is set to utf8 while collation is set to utf8_unicode_ci.
The database table:
CREATE TABLE `RssFeedItem` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`feedId` smallint(5) unsigned NOT NULL,
`title` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
`url` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`text` mediumtext COLLATE utf8_unicode_ci,
`textSha1` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `url` (`url`),
KEY `feedId` (`feedId`),
CONSTRAINT `RssFeedItem_ibfk_1` FOREIGN KEY (`feedId`) REFERENCES `RssFeed` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6370 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
I've also set up a test page in order to see if the problem could be my database setup, but the test page prints everything just fine. The test page uses PDO to select all data, and prints it on a simple html page.
Does anyone know what the problem might be? I've tried searching around with no luck besides this link, but I haven't found anything that might help me.
I did eventually end up solving this myself. The problem was caused by the separate script responsible for populating my database with data. This was solved by running a query with SET NAMES utf8 before inserting data to the database. The original data was pulled out, and then sent back in after running said query.
The reason for it working outside laravel, was simply because the said query wasn't executed on my test page. If i ran the query before retrieving the data, it came out with the wrong encoding because the query stated that the data was encoded as utf8, when it really wasn't.
When using the query
select distinct(column_name) as column_name, data_type from information_schema.columns
where table_name='reg_add_ons' order by ordinal_position
I get an extra column on my dev server. On my local server everything works fine. This is the only table this happens on. I have tried dropping the table and adding it again with this statement
delimiter $$
CREATE TABLE `reg_add_ons` (
`add_on_id` int(10) NOT NULL AUTO_INCREMENT,
`eventcode` varchar(20) DEFAULT NULL,
`add_on_desc` varchar(250) DEFAULT NULL,
`add_on_price` decimal(10,2) DEFAULT NULL,
`add_on_detail` text,
`add_on_label` varchar(100) DEFAULT NULL,
`add_on_choices` varchar(200) DEFAULT NULL,
`image_name` varchar(100) DEFAULT NULL,
`internal_only` varchar(2) DEFAULT NULL,
`assign_code` text,
`reg_status` varchar(50) DEFAULT 'Active',
PRIMARY KEY (`add_on_id`)
) ENGINE=MyISAM AUTO_INCREMENT=89 DEFAULT CHARSET=latin1$$
I have a bit of the flu so this is not making sense to me right now.
Dev box is a Windows 7 machine running MySQL 5.6.10
Localhost is Windows 7 running MySQL 5.5.24
Production server is Linux MySQL 5.0.45
It is only this one table on this one machine (Dev) having problems. what is the field require_validation? Where does it come from?
Any insight is appreciated
I have installed a forum module for SS. I'm currently using version 2.3.3
After I installed the forum file on the back end I receive a message that says “File not found” on Firefox, and “This webpage is not found” on Google Chrome.
I followed all the instructions but I still get the error message.
Also, when I run http://mysite.co.za/dev/build/?flush=1, I receive this error message
>[User Error]
Couldn't run query:
CREATE TABLE `ForumCategory` (
`ID` int(11) not null auto_increment,
`ClassName` enum('ForumCategory') character set utf8 collate utf8_general_ci default 'ForumCategory',
`Created` datetime,
`LastEdited` datetime,
`Title` varchar(100) character set utf8 collate utf8_general_ci,
`StackableOrder` varchar(2) character set utf8 collate utf8_general_ci,
`ForumHolderID` int(11) not null default '0',
index `ForumHolderID` (ForumHolderID),
index `ClassName` (ClassName), primary key (ID) ) TYPE=MyISAM
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 14
GET /dev/build/flush=1
Line 401 in /home/neutrog7/public_html/sapphire/core/model/MySQLDatabase.php"
Your best bet is to upgrade to a newer version of SilverStripe. I'd recommend upgrading to 3.0 if you can, but if it becomes too much effort to upgrade to 3.0 then try 2.4.
If you really can't upgrade at this stage, you'll need to replace "TYPE" with "ENGINE" in MySQLDatabase.php. But, really, you're going to be mostly on your own if you go down this path and upgrading would be much better.
I worked on a site locally through my Laptop. I have a table named blog and it has the fields post_id, title, markdown, author, added, and modified.
The fields Added and Modified are both DATETIME's.
When a user makes a blog post, PHP runs this query successfully: INSERT INTO blog (title, author, markdown, added) VALUES ('BLA', 'BLA', 'BLA', NOW())
I've gone into phpMyAdmin and ran the exact same query with working results.
Now, I exported my exact database into the server today and I noticed that no posts were being stored in the DB, so I tried running it through phpMyAdmin's SQL and it gave me the error Field 'modified' doesn't have a default value.
Why would this be happening? In my database, the default for both is None so I'm quite confused on what could be causing this.
My Laptop has PHP 5.3.1 and MySQL 5.1.41 (I installed XAMPP.)
The Server has PHP 5.3.5 and MySQL 5.5.8 (Out of desperation I installed the newest versions. The server was originally running MySQL 5.1 and a lower version of PHP.)
This has been killing me, hopefully someone knows what's wrong with this or how to fix it.
Edit: Here are the SHOW CREATE TABLE blog results.
Laptop:
| blog | CREATE TABLE `blog` (
`post_id` mediumint(9) NOT NULL AUTO_INCREMENT,
`title` varchar(160) NOT NULL,
`author` varchar(100) NOT NULL,
`markdown` longtext NOT NULL,
`added` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`post_id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 |
Server:
| blog | CREATE TABLE `blog` (
`post_id` mediumint(9) NOT NULL AUTO_INCREMENT,
`title` varchar(160) NOT NULL,
`author` varchar(100) NOT NULL,
`markdown` longtext NOT NULL,
`added` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`post_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 |
Auto Increments are different because of my tests.
ALTER TABLE blog CHANGE modified modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
Or, more rarely, you might have a buggy version of MySQL on your server.
*I might have the syntax imperfect, I referred to the last comment on ALTER TABLE at the bottom of the manual page.
First: are you sure the data on your laptop exactly the same as the data on the server? Maybe you're not getting this error on your laptop because the default values are set on your laptop table somehow and not the server -- possibly an issue with how you exported the data.
When you say, the default is "None" do you mean NULL or do you mean literally the word "None"?
If both fields are datetime fields, then set the default to NOW() or, if you prefer to not have an actual date and time by default, use a string like "0000-00-00 00:00:00", or the JDBC friendly "0001-01-01 00:00:00".
Compare the structure of each table with the following command in a mysqlclient:
SHOW CREATE TABLE blog;
Dump the DDL from both versions using
$ mysqldump --no-data dabasename
and compare them (and check the man page for mysqldump(1) as I'm flying by memory here.)
Make sure you're using the same exact table description and that both versions are using the same engine.