Error: MySQL shutdown unexpectedly. 11:11:48 AM [mysql] This may be due to a blocked port, missing dependencies,

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 ibdata1 file. You could destroy all your databases.

Instead, first try using the MySQL backup folder which is included with XAMPP. So do next steps:

  1. Rename folder mysql/data to mysql/data_old
  2. Make a copy of mysql/backup folder and name it as mysql/data
  3. Copy all your database folders from mysql/data_old into mysql/data (except mysqlperformance_schema, and phpmyadmin folders)
  4. Copy mysql/data_old/ibdata1 file into mysql/data folder
  5. Start MySQL from XAMPP control panel

#1010 – Error dropping database

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 !!

default value in Laravel migration

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();

#1101 error in mysql / phpmyadmin

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):

  • Edit /my.ini and look for linesql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  • Replace it withsql_mode='MYSQL40'
  • Restart the MySQL service (assuming that it is mysql5)net stop mysql5 net start mysql5

If you have root/admin access you might be able to execute

mysql_query("SET @@global.sql_mode='MYSQL40'");

#2006 – MySQL server has gone away

MySQL/MariaDB related:

  • 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

ignore time in datetime mysql in select in laravel 8

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')

update query with concat in mysql using php

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 ;
	
}

मेरी वेबसाइट कहाँ होस्ट करें | where to host my website

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.

Compute

Build and release faster with scalable compute products in the cloud. DigitalOcean provides flexible server configurations sized for any application, industry leading price to performance, and predictable pricing that is the same across regions and usage volumes.

Storage

Store and quickly access any amount of data reliably in the cloud. DigitalOcean offers several kinds of storage depending on your needs.

Networking

Secure and control the traffic to your applications with your own private network, traffic filtering, and load balancing.

Databases

Combine the power of our core VM platform with a fully managed MongoDB, MySQL, PostgreSQL, and Redis databases to give your application the performance it needs – without the operational demands that come with building and running your own database server.

Developer tools

Manage resources programmatically and integrate across the developer ecosystem.

Management tools

Monitor and manage, both your software and your team.

What is pluck in MySQL select query

Without pluck

 $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
            }
        ],

With pluck

 $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
        }

multiple database laravel 8

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=mydatabase

DB_USERNAME=aditya

DB_PASSWORD=aditya

   

DB_CONNECTION_SECOND=mysql

DB_HOST_SECOND=127.0.0.1

DB_PORT_SECOND=3306

DB_DATABASE_SECOND=mydatabase2

DB_USERNAME_SECOND=aditya

DB_PASSWORD_SECOND=aditya

config/database.php

<?php

  

use Illuminate\Support\Str;

  

return [

   

    'default' => env('DB_CONNECTION', 'mysql'),

   

    'connections' => [

        .....

   

        'mysql' => [

            'driver' => 'mysql',

            'url' => env('DATABASE_URL'),

            'host' => env('DB_HOST', '127.0.0.1'),

            'port' => env('DB_PORT', '3306'),

            'database' => env('DB_DATABASE', 'forge'),

            'username' => env('DB_USERNAME', 'forge'),

            'password' => env('DB_PASSWORD', ''),

            'unix_socket' => env('DB_SOCKET', ''),

            'charset' => 'utf8mb4',

            'collation' => 'utf8mb4_unicode_ci',

            'prefix' => '',

            'prefix_indexes' => true,

            'strict' => true,

            'engine' => null,

            'options' => extension_loaded('pdo_mysql') ? array_filter([

                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),

            ]) : [],

        ],

        'mysql2' => [

            'driver' => env('DB_CONNECTION_SECOND'),

            'host' => env('DB_HOST_SECOND', '127.0.0.1'),

            'port' => env('DB_PORT_SECOND', '3306'),

            'database' => env('DB_DATABASE_SECOND', 'forge'),

            'username' => env('DB_USERNAME_SECOND', 'forge'),

            'password' => env('DB_PASSWORD_SECOND', ''),

            'unix_socket' => '',

            'charset' => 'utf8mb4',

            'collation' => 'utf8mb4_unicode_ci',

            'prefix' => '',

            'prefix_indexes' => true,

            'strict' => true,

            'engine' => null,

        ],
<?php

.....

public function up()

{

    Schema::create('blog', function (Blueprint $table) {

        $table->increments('id');

        $table->string('title');

        $table->string('body')->nullable();

        $table->timestamps();

    });

}
<?php

.....

public function up()

{

    Schema::connection('mysql2')->create('blog', function (Blueprint $table) {

        $table->increments('id');

        $table->string('title');

        $table->string('body')->nullable();

        $table->timestamps();

    });

}
<?php

   

namespace App;

  

use Illuminate\Database\Eloquent\Model;

   

class Blog extends Model

{

}
<?php

   

namespace App;

  

use Illuminate\Database\Eloquent\Model;

   

class Blog extends Model

{

    protected $connection = 'mysql2';

}
<?php

  

class BlogController extends BaseController

{

    public function getRecord()

    {

        $blogModel = new Blog;

        $find = $blogModel->find(1);

        return $find;

    }

}
<?php

  

class BlogController extends BaseController

{

    public function getRecord()

    {

        $blogModel = new Blog;

        $blogModel->setConnection('mysql2');

        $find = $blogModel->find(1);

        return $find;

    }

}
$blogs = DB::table("blog")->get();

print_r($blogs);
$blogs = DB::connection('mysql2')->table("blog")->get();

print_r($blogs);