April 21, 2022 in MySql
#1030 – Got error 176 “Read page with wrong checksum” from storage engine Aria
Follow the below steps.
April 21, 2022 in MySql
Follow the below steps.
April 21, 2022 in MySql
Error: MySQL shutdown unexpectedly. 11:11:48 AM [mysql] This may be due to a blocked port, missing dependencies, 11:11:48 AM [mysql] improper privileges, a crash, or a shutdown by another method. 11:11:48 AM [mysql] Press the Logs button to view error logs and check 11:11:48 AM [mysql] the Windows Event Viewer for more clues 11:11:48 AM [mysql] If you need more help, copy and post this 11:11:49 AM [mysql] entire log window on the forums
IMPORTANT: do NOT delete
ibdata1file. You could destroy all your databases.
Instead, first try using the MySQL backup folder which is included with XAMPP. So do next steps:
mysql/data to mysql/data_oldmysql/backup folder and name it as mysql/datamysql/data_old into mysql/data (except mysql, performance_schema, and phpmyadmin folders)mysql/data_old/ibdata1 file into mysql/data folderApril 21, 2022 in MySql
A database is represented by a directory under the data directory (usually /var/lib/mysql), and the directory is intended for storage of table data.
The DROP DATABASE statement will remove all table files and then remove the directory that represented the database. It will not, however, remove non-table files, whereby making it not possible to remove the directory.
MySQL displays an error message when it cannot remove the directory
you can really drop the database manually by removing any remaining files in the database directory and then the directory itself.
For phpmyadmin, go to xampp\mysql\data and simply delete the database folder. Worked for me !!
April 21, 2022 in Laravel, MySql
Put the default value in single quote and it will work as intended. An example of migration:
$table->increments('id');
$table->string('name');
$table->string('url')->nullable();
$table->string('country')->default('india');
$table->tinyInteger('status')->default('1');
$table->timestamps();
April 21, 2022 in MySql, Tips and Tricks
1101 – BLOB, TEXT, GEOMETRY or JSON column ‘answer’ can’t have a default value
Probably your development environment allows the defaults and the production environment doesn’t. You can either upgrade your production system or not use that feature.
How to disable strict mode in MySQL 5 (Windows):
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"sql_mode='MYSQL40'net stop mysql5 net start mysql5If you have root/admin access you might be able to execute
mysql_query("SET @@global.sql_mode='MYSQL40'");
April 15, 2022 in MySql, Tips and Tricks
wait_timeout – Time in seconds that the server waits for a connection to become active before closing it.interactive_timeout – Time in seconds that the server waits for an interactive connection.max_allowed_packet – Maximum size in bytes of a packet or a generated/intermediate string. Set as large as the largest BLOB, in multiples of 1024.Example of my.cnf:
[mysqld]
# 8 hours
wait_timeout = 28800
# 8 hours
interactive_timeout = 28800
max_allowed_packet = 256M
If you are using xampp server :
Go to xampp -> mysql -> bin -> my.ini
Change below parameter :
max_allowed_packet = 500M
innodb_log_file_size = 128M
February 24, 2022 in Laravel, MySql, Tips and Tricks
They do the SQL DATE() work for you, and manage the differences of SQLite.
Your result can be achieved as so:
->whereDate('date', '<=', '2014-07-10')
Though the above method is convenient, as noted by Arth it is inefficient on large datasets, because the DATE() SQL function has to be applied on each record, thus discarding the possible index.
Here are some ways to make the comparison (but please read notes below):
->where('date', '<=', '2014-07-10 23:59:59')
->where('date', '<', '2014-07-11')
// '2014-07-11'
$dayAfter = (new DateTime('2014-07-10'))->modify('+1 day')->format('Y-m-d');
->where('date', '<', $dayAfter)
->whereDate('date','=','2014-07-10')
->whereDate('date', '<=', '2014-07-10')
December 22, 2021 in MySql, Php, Tips and Tricks
public function UpdateMyTask($Request,$user_id)
{
$Query='';
//$Request['ip_addr']=$_SERVER['REMOTE_ADDR'];
//$Request['user_agent']=$_SERVER['HTTP_USER_AGENT'];
// $user_agent= strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Mobile"))?"Mobile":strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Windows"))?"Windows":"Android" ;
if(strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Mobile")))
{
$user_agent="Mobile";
}else if(strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Windows")))
{
$user_agent="Windows";
}else if(strlen(stristr($_SERVER['HTTP_USER_AGENT'],"Android")))
{
$user_agent="Android";
}
foreach($Request as $Index => $Value)
{
if($Index == 'task_id')
{
$task_id= ($Value);
}
$Query.=$Index."='".mysqli_real_escape_string($this->link,$Value)."',";
}
$Query= rtrim($Query,',').",update_date_time=concat(update_date_time,',','".date('H:i')."'),ip_addr=concat(ip_addr,',','".$_SERVER['REMOTE_ADDR']."'),user_agent=concat(user_agent,',','".$user_agent."') where task_id='".$task_id."' and user_id='".$user_id."'";
$Query="update mytask set ".$Query;
$result=$this->NonQuery($Query);
return $result ;
}
November 3, 2021 in MySql, Technology
Digitalocean
DigitalOcean is a values-driven organization. Here is what we believe in.
Our community is bigger than just us
We foster the global developer and entrepreneurial communities because they are the source of our ideas and innovation and essential to our sustained growth.
Simplicity in all we DO
We make decisions that eliminate complexity and obstacles to our moving fast so we can enable our customers to focus on testing their Ideas, building their businesses and realizing their dreams.
We speak up when we have something to say and listen when others DO
We create an environment where we are transparent and respectful so we are confident in bringing our best selves on behalf of our customers and each other, every day.
We are accountable to deliver on our commitments
Earning trust every day is our core value proposition to our customers and to each other. We must be trustworthy, because the opportunity to serve our customers is larger than any one of us.
Love is at our core
Underlying everything we do, love for our customers and our DO is essential to realizing our fullest potential.
September 28, 2021 in MySql, Tips and Tricks
$data['category'] = DB::table('table_name')->select('category', DB::raw('count(*) as total'))->groupBy('category')->where('date','>=',$start_date)->where('date','<=',$end_date)->get();
"category": [
{
"category": "Car",
"total": 2
},
{
"category": "vehicle",
"total": 1
}
],
$data['category'] = DB::table('table_name')->select('category', DB::raw('count(*) as total'))->groupBy('category')->where('date','>=',$start_date)->where('date','<=',$end_date)->pluck('total','category')->all();
"category": {
"Car": 2,
"vehicle": 1
}