Posted on September 4, 2021, 6:02 pm, by admin, under
mysql.
Step 1 mysql> show variables like ‘sql_mode’ ; | sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION Step 2 Add to mysqld.cnf <pre lang="bash"> sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION Step 3 Restart mysql
Posted on January 24, 2020, 3:34 pm, by admin, under
apache,
mysql.
I had a problem with a container which wouldn’t start due to a bad config change I made. I was able to copy the file out of the stopped container and edit it. something like: docker cp test-mysql:/etc/mysql/my.cnf . Edit it and copy back docker cp my.cnf test-mysql:/etc/mysql/my.cnf docker start mysql docker exec -ti mysql […]
Posted on November 27, 2019, 11:27 pm, by admin, under
mysql,
php.
<?php $dbname = ‘dbname’; $dbuser = ‘user’; $dbpass = ‘pass’; $dbhost = ‘hostname’; $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to ‘$dbhost’"); mysql_select_db($dbname) or die("Could not open the db ‘$dbname’"); $test_query = "SELECT 1,2,3,4 FROM yourtable"; $result = mysql_query($test_query); $tblCnt = 0; while($tbl = mysql_fetch_array($result)) { $tblCnt++; echo $tbl[0]."<br />\n"; echo […]
Posted on November 22, 2019, 12:00 pm, by admin, under
mysql.
Posted on August 20, 2019, 2:49 pm, by admin, under
mysql.
SELECT DATE_FORMAT(FROM_UNIXTIME(yourfield), ‘%e %b %Y’) FROM yourtable;
Posted on February 28, 2019, 5:30 pm, by admin, under
mysql.
Для начала нужно понять, когда хорошо использовать Sql? Когда данные структурированы и легко ложатся на модель кортежей. Если же данные имеют привычку менять схему/структуру, то можно использовать NoSql. Единственное, что у NoSql баз проблемы с ACID (транзакциями, атомарностью и т.п.)
Posted on September 10, 2018, 3:24 pm, by admin, under
mysql.
SHOW COLUMNS FROM Tablename WHERE FIELD = "Fieldname";
Posted on February 28, 2018, 12:49 pm, by admin, under
mysql.
DELETE FROM main_table USING main_table, main_table e1 WHERE main_table.id > e1.id AND main_table.entity_id = e1.entity_id;
Posted on February 16, 2018, 11:35 am, by admin, under
bash,
mysql.
cat file.csv | awk -F, ‘{print "INSERT INTO mytable VALUES ("$1",*"$2"*,"$3");"}’ echo https://api.trustpilot.com/tagname/tags | awk -F/ ‘{print $2}’
Posted on January 16, 2018, 9:34 am, by admin, under
mysql.
CREATE TABLE newtable LIKE oldtable;