How to Check MySQL Server Version in Laravel?

15-Dec-2022

.

Admin

How to Check MySQL Server Version in Laravel?

Hello Friends,

Today, I will let you know example of how to check mysql server version in laravel. I’m going to show you about how to check which database is used in laravel. This article will give you simple example of how do i check my current version of laravel. This post will give you simple example of how to get mysql version..

In this post, I will share with you how to get the MySQL Version using Laravel. Lately, I need to determine what MySQL version I'm using and maybe you need it also.

Step 1: Install Laravel


This is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:

composer create-project laravel/laravel example-app

App/Http/Controllers/HomeController

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller

{

/**

* Write Your Code..

*

* @return string

*/

public function index()

{

$sqlVersion = \DB::select( \DB::raw('SHOW VARIABLES LIKE "%version%"') );

print_r($sqlVersion);die;

}

}

Output

Array

(

[0] => stdClass Object

(

[Variable_name] => in_predicate_conversion_threshold

[Value] => 1000

)

[1] => stdClass Object

(

[Variable_name] => innodb_version

[Value] => 10.4.21

)

[2] => stdClass Object

(

[Variable_name] => protocol_version

[Value] => 10

)

[3] => stdClass Object

(

[Variable_name] => slave_type_conversions

[Value] =>

)

[4] => stdClass Object

(

[Variable_name] => system_versioning_alter_history

[Value] => ERROR

)

[5] => stdClass Object

(

[Variable_name] => system_versioning_asof

[Value] => DEFAULT

)

[6] => stdClass Object

(

[Variable_name] => tls_version

[Value] => TLSv1.1,TLSv1.2,TLSv1.3

)

[7] => stdClass Object

(

[Variable_name] => version

[Value] => 10.4.21-MariaDB

)

[8] => stdClass Object

(

[Variable_name] => version_comment

[Value] => mariadb.org binary distribution

)

[9] => stdClass Object

(

[Variable_name] => version_compile_machine

[Value] => x64

)

[10] => stdClass Object

(

[Variable_name] => version_compile_os

[Value] => Win64

)

[11] => stdClass Object

(

[Variable_name] => version_malloc_library

[Value] => system

)

[12] => stdClass Object

(

[Variable_name] => version_source_revision

[Value] => 4902b0fdc91cc6dc169dd2322daf966a2eeafdd8

)

[13] => stdClass Object

(

[Variable_name] => version_ssl_library

[Value] => WolfSSL 4.8.0

)

)

I hope it can help you...

#Laravel