i'm tring to add geoname allcountries in my database
after adding some data show MySQL server has gone away
allmost after 37890 rows then show show MySQL server has gone
DROP TABLE IF EXISTS `geo_allcountries`;
CREATE TABLE `geo_allcountries` (
`geonameid` INT(11) NOT NULL,
`name` VARCHAR(200) DEFAULT NULL,
`asciiname` VARCHAR(200) DEFAULT NULL,
`alternatenames` VARCHAR(4000) DEFAULT NULL,
`latitude` DECIMAL(10 , 7 ) DEFAULT NULL,
`longitude` DECIMAL(10 , 7 ) DEFAULT NULL,
`fclass` CHAR(1) DEFAULT NULL,
`fcode` VARCHAR(10) DEFAULT NULL,
`country` VARCHAR(2) DEFAULT NULL,
`cc2` VARCHAR(60) DEFAULT NULL,
`admin1` VARCHAR(20) DEFAULT NULL,
`admin2` VARCHAR(80) DEFAULT NULL,
`admin3` VARCHAR(20) DEFAULT NULL,
`admin4` VARCHAR(20) DEFAULT NULL,
`population` INT(11) DEFAULT NULL,
`elevation` INT(11) DEFAULT NULL,
`gtopo30` INT(11) DEFAULT NULL,
`timezone` VARCHAR(40) DEFAULT NULL,
`moddate` DATE DEFAULT NULL,
PRIMARY KEY (`geonameid`),
KEY `name` (`name`),
KEY `asciiname` (`asciiname`),
KEY `latitude` (`latitude`),
KEY `longitude` (`longitude`),
KEY `fclass` (`fclass`),
KEY `fcode` (`fcode`),
KEY `country` (`country`),
KEY `cc2` (`cc2`),
KEY `admin1` (`admin1`),
KEY `population` (`population`),
KEY `elevation` (`elevation`),
KEY `timezone` (`timezone`)
) ENGINE=MYISAM DEFAULT CHARSET=UTF8 COLLATE UTF8_UNICODE_CI;
ALTER TABLE `geo_allcountries` DISABLE KEYS;
LOAD DATA LOCAL INFILE 'D:/allCountries.txt'
INTO TABLE `geo_allcountries`
CHARACTER SET 'UTF8';
ALTER TABLE `geo_allcountries`
ADD COLUMN `fclasscode` CHAR(7) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL AFTER `fcode`;
UPDATE `geo_allcountries`
SET
`fclasscode` = CONCAT(`fclass`, '.', `fcode`);
UPDATE `geo_allcountries`
SET `fclasscode` = ''
WHERE
`fclasscode` NOT REGEXP '[A-Z]{1}.[A-Z]{1,5}';
ALTER TABLE `geo_allcountries` ADD INDEX `fclasscode` (`fclasscode` ASC);
ALTER TABLE `geo_allcountries` ENABLE KEYS;
add this line have the same error
SET FOREIGN_KEY_CHECKS = ON;
php config
max_allowed_packet = 2048M
$cfg['ExecTimeLimit'] =0;
with this same error
$cfg['ExecTimeLimit'] =3000;
post_max_size=1800M
upload_max_filesize=2048M
max_execution_time=2048
max_input_time=1700M
memory_limit=1048M
file size of geoname allcountries.txt file is 1.38GB
how to solve this and where is a problem
I spend much time on this issue but i'm unable to slove
please find out and how to solve this
Related
I am creating a database that will store 'graduate details'. I have been able to set the ID to auto increment, Unique and also my primary key that start from 1...
I also want to make the certificate number field unique and auto-increment value in an increasing order that will start from 00001.
Please any help on how to go about this will be very appreciated. Thank you.
This is the MYSQL code for the database below;
CREATE TABLE IF NOT EXISTS `graduates` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`f_name` varchar(25) NOT NULL,
`l_name` varchar(25) NOT NULL,
`gender` varchar(6) DEFAULT NULL,
`address` varchar(100) DEFAULT NULL,
`city` varchar(15) DEFAULT NULL,
`region` varchar(30) DEFAULT NULL,
`phone` varchar(15) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`certificate_number` int(50) NOT NULL AUTO_INCREMENT,
`programme` varchar(50) CHARACTER SET utf8mb4 NOT NULL,
`marks` int(10) NOT NULL,
`college_name` varchar(50) CHARACTER SET utf8mb4 NOT NULL,
`date_of_birth` date DEFAULT NULL,
`created_by` int(10) UNSIGNED NOT NULL DEFAULT 0,
`created_at` date DEFAULT NULL,
`updated_by` int(10) UNSIGNED NOT NULL DEFAULT 0,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `certificate_number` (`certificate_number`)
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8;
i have this table structure:
CREATE TABLE `schedules_trackings` (
`id` bigint(20) NOT NULL,
`device_id` bigint(20) UNSIGNED NOT NULL,
`schedule_id` bigint(20) UNSIGNED NOT NULL,
`latitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`longitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`altitude` double DEFAULT NULL,
`accuracy` double DEFAULT NULL,
`heading` double DEFAULT NULL,
`speed` double DEFAULT NULL,
`activity` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`battery` double DEFAULT NULL,
`segmentid` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`uuid` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`odometer` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE `schedules_trackings`
ADD PRIMARY KEY (`id`),
ADD KEY `device_id` (`device_id`,`schedule_id`,`created_at`) USING BTREE,
ADD KEY `schedule_id` (`id`,`created_at`) USING BTREE;
ALTER TABLE `schedules_trackings`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
the mobile device sent me each 10 second the coordinates and the progressive count of the odometer.
the problem i need to remove from this count the distance made with a speed more than 30kmh, i have the speed data but i don't have idea how to remove it from the progressive count.
any solution with mysql query or php?
some example data:
lat1 - lng1 - speed1 - 0mt
lat2 - lng2 - speed2 - 50mt
lat3 - lng3 - speed3 - 100mt
if i only remove for example the row with speed 2 i will get anyway on the last point 100mt but this is not right way. excluding speed 2 my real distance is 50mt this is very simple example, the real query have to work on 25k record avarage.
the target is to get the distance made by walk and discard the distance made by car.
I have the following table in mysql:
CREATE TABLE `kampbs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(20) COLLATE utf8_danish_ci DEFAULT NULL,
`k1` varchar(1) COLLATE utf8_danish_ci DEFAULT NULL,
`k1r` varchar(10) COLLATE utf8_danish_ci DEFAULT NULL,
`k2` varchar(1) COLLATE utf8_danish_ci DEFAULT NULL,
`k2r` varchar(10) COLLATE utf8_danish_ci DEFAULT NULL,
`k3` varchar(1) COLLATE utf8_danish_ci DEFAULT NULL,
`k3r` varchar(10) COLLATE utf8_danish_ci DEFAULT NULL,
`week` int(2) DEFAULT NULL,
`grp` varchar(11) COLLATE utf8_danish_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci
I have a form, that INSERT INTO the fields in the database, but it should only be possible to insert once a week pr user. So it should check if the column 'user' and 'week' are unique together. Make sense? :/
Let's say the user 'freak' submit in week 13, he shouldn't be able to submit once again in week 13.
I use the following $sql:
$sql = "INSERT INTO kampbs(user, k1, k1r, k2, k2r, k3, k3r, week, grp) VALUES('$username', '$k1', '$k1r', '$k2', '$k2r', '$k3', '$k3r', '$week', '$grp')";
You can add a constraint to your table, so that the user / week couple is forced to be unique
ALTER TABLE `kampbs` ADD UNIQUE `unique_index`(`user`, `week`);
I keep on getting the below error message when I try to enter some important records I accentually deleted.
Duplicate entry 'EMIR2023 ' for key 'flightNo'
Is there a way in the phpMyAdmin environment I can disable the UNIQUE KEY then activate it when I am done with inserting the records?
Find below the structure of my table, I hope it helps
--
-- Table structure for table `flightSched`
--
CREATE TABLE IF NOT EXISTS `flightSched` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`timePeriod` time DEFAULT '00:00:00',
`depOrArriv` varchar(9) DEFAULT NULL,
`flightNo` varchar(9) NOT NULL,
`airline` varchar(20) DEFAULT NULL,
`dest` varchar(30) DEFAULT NULL,
`origin` varchar(30) DEFAULT NULL,
`depature` time DEFAULT '00:00:00',
`don` set('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday') DEFAULT NULL,
`arrivalTime` datetime DEFAULT '0000-00-00 00:00:00',
`arrivalTimeSec` varchar(28) DEFAULT NULL,
`status` varchar(15) NOT NULL,
`image_type` varchar(25) DEFAULT NULL,
`image` blob NOT NULL,
`image_size` varchar(25) DEFAULT NULL,
`image_name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `flightNo` (`flightNo`),
UNIQUE KEY `arrivalTime_2` (`arrivalTime`),
KEY `arrivalTime` (`arrivalTime`),
KEY `arrivalTime_3` (`arrivalTime`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=537 ;
Looking forward to your reply :-)
Try unique_checks
SET unique_checks=0;
... import operation ...
SET unique_checks=1;
check reference
this code tested with both server and local phpmyadmin
on localhost it returned results as expected
on server it returned a good result but when passing the dr_name it returns empty result
here is the code:
SELECT * FROM doctor WHERE dr_name LIKE '%غا%' AND specialization=12 AND state=6
the only deference between server and local is that the server mysql engine is myisam and innodb on localhost
this is the create table statement:
CREATE TABLE IF NOT EXISTS `doctor` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dr_name` varchar(65) NOT NULL,
`dr_name_e` varchar(65) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`unique_name` varchar(75) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`pass` char(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`nickname` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`specialization` int(11) NOT NULL,
`state` tinyint(4) NOT NULL,
`scientific_degree` int(11) DEFAULT NULL,
`university` int(11) DEFAULT NULL,
`grad_year` smallint(6) DEFAULT NULL,
`show_degree` tinyint(1) DEFAULT NULL,
`show_univ` tinyint(1) DEFAULT NULL,
`show_grad_year` tinyint(1) DEFAULT NULL,
`appendices` varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`picture` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0',
`views` bigint(20) DEFAULT '0',
`search_result` bigint(20) DEFAULT '0',
`gender_male` tinyint(1) DEFAULT NULL,
`agent` int(11) DEFAULT NULL,
`next_step` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_name` (`unique_name`),
KEY `university` (`university`),
KEY `scientific_degree` (`scientific_degree`),
KEY `specialization` (`specialization`),
KEY `agent` (`agent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=31 ;