{"id":2220,"date":"2024-09-07T08:47:01","date_gmt":"2024-09-07T08:47:01","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=2220"},"modified":"2024-09-14T07:35:19","modified_gmt":"2024-09-14T07:35:19","slug":"troubleshooting-base-table-or-view-not-found-1146-table-example-sessions-doesnt-exist-error-in-laravel","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/troubleshooting-base-table-or-view-not-found-1146-table-example-sessions-doesnt-exist-error-in-laravel\/","title":{"rendered":"Troubleshooting Base table or view not found: 1146 Table &#8216;example.sessions&#8217; doesn&#8217;t exist Error in Laravel"},"content":{"rendered":"\n<p>The error message <code>SQLSTATE[42S02]: Base table or view not found: 1146<\/code> indicates that Laravel is trying to access a database table called <code>sessions<\/code> that doesn\u2019t seem to be present in the specified database <code>cloud18i_dbpethu<\/code>.<\/p>\n\n\n\n<p>In Laravel, the <code>sessions<\/code> table is used when you are storing session data in the database. By default, Laravel uses file-based session storage, but it can be configured to use database storage for better scalability and sharing sessions across multiple instances.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Diagnosing the Problem<\/h4>\n\n\n\n<p>In your case, it seems that your application\u2019s session driver was changed from <code>file<\/code> to <code>database<\/code> in the <code>.env<\/code> configuration file. When this change was made, Laravel attempted to store session data in the database, which led to the error because the <code>sessions<\/code> table did not exist.<\/p>\n\n\n\n<p>Here\u2019s a closer look at what might have gone wrong:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Session Driver Change<\/strong>: Changing the session driver to <code>database<\/code> in the <code>.env<\/code> file tells Laravel to use the database to manage sessions. This requires a <code>sessions<\/code> table to be present in the database.<\/li>\n\n\n\n<li><strong>Missing Table<\/strong>: If the <code>sessions<\/code> table does not exist, Laravel will throw an error when trying to access it. This is likely what happened in your case.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Solution<\/h2>\n\n\n\n<p>To resolve this issue, you have two main options:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Revert to File-Based Sessions<\/strong>If you do not need to store sessions in the database, you can revert to the default file-based session storage. To do this, follow these steps:\n<ul class=\"wp-block-list\">\n<li>Open your <code>.env<\/code> file, which is located in the root directory of your Laravel application.<\/li>\n\n\n\n<li>Find the line that specifies the session driver. It should look something like this:<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>SESSION_DRIVER=database<\/code><\/pre>\n\n\n\n<p>Change it back to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SESSION_DRIVER=file<\/code><\/pre>\n\n\n\n<p>Save the <code>.env<\/code> file and clear the application cache by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan config:cache<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>More topics on Bug fixing:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"6WIsP8qvWn\"><a href=\"https:\/\/www.devopssupport.in\/blog\/mysql-error-1932-table-doesnt-exist-in-engine\/\">MySQL Error #1932: &#8220;Table Doesn&#8217;t Exist in Engine&#8221;<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;MySQL Error #1932: &#8220;Table Doesn&#8217;t Exist in Engine&#8221;&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/mysql-error-1932-table-doesnt-exist-in-engine\/embed\/#?secret=deShp0FGW1#?secret=6WIsP8qvWn\" data-secret=\"6WIsP8qvWn\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"kRd3I9PCmO\"><a href=\"https:\/\/www.devopssupport.in\/blog\/neterr_incomplete_chunked_encoding-200-ok\/\">net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/neterr_incomplete_chunked_encoding-200-ok\/embed\/#?secret=NUK70G7ogD#?secret=kRd3I9PCmO\" data-secret=\"kRd3I9PCmO\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"iDkHbd4m4P\"><a href=\"https:\/\/www.devopssupport.in\/blog\/fixing-429-too-many-requests-in-laravel\/\">Fixing 429 Too Many Requests in Laravel<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Fixing 429 Too Many Requests in Laravel&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/fixing-429-too-many-requests-in-laravel\/embed\/#?secret=O710YRpJ5j#?secret=iDkHbd4m4P\" data-secret=\"iDkHbd4m4P\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"i1y6mP3wmk\"><a href=\"https:\/\/www.devopssupport.in\/blog\/1834-2\/\">Resolving the &#8216;type &#8216;Null&#8217; is not a subtype of type &#8216;String&#8221; Error in Flutter<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Resolving the &#8216;type &#8216;Null&#8217; is not a subtype of type &#8216;String&#8221; Error in Flutter&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/1834-2\/embed\/#?secret=P7MPfW2Cle#?secret=i1y6mP3wmk\" data-secret=\"i1y6mP3wmk\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"zOsxo3qshx\"><a href=\"https:\/\/www.devopssupport.in\/blog\/solving-the-libandroid-emu-metrics-dll-not-found-error-in-android-development\/\">Solving the \u201clibandroid-emu-metrics.dll Not Found\u201d Error in Android Development<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Solving the \u201clibandroid-emu-metrics.dll Not Found\u201d Error in Android Development&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/solving-the-libandroid-emu-metrics-dll-not-found-error-in-android-development\/embed\/#?secret=DPMO8wQE6k#?secret=zOsxo3qshx\" data-secret=\"zOsxo3qshx\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"uwYCzKoLUW\"><a href=\"https:\/\/www.devopssupport.in\/blog\/resolving-flutter-target-file-lib-main-dart-not-found-issue\/\">Resolving &#8220;Flutter: Target file &#8216;lib\/main.dart&#8217; not found&#8221; Issue<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Resolving &#8220;Flutter: Target file &#8216;lib\/main.dart&#8217; not found&#8221; Issue&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/resolving-flutter-target-file-lib-main-dart-not-found-issue\/embed\/#?secret=qP0Wuvde65#?secret=uwYCzKoLUW\" data-secret=\"uwYCzKoLUW\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"EfCdNX6V8K\"><a href=\"https:\/\/www.devopssupport.in\/blog\/troubleshooting-laravel-laravel-emergency-unable-to-create-configured-logger-using-emergency-logger\/\">Troubleshooting Laravel: &#8220;laravel.EMERGENCY: Unable to create configured logger. Using emergency logger.&#8221;<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Troubleshooting Laravel: &#8220;laravel.EMERGENCY: Unable to create configured logger. Using emergency logger.&#8221;&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/troubleshooting-laravel-laravel-emergency-unable-to-create-configured-logger-using-emergency-logger\/embed\/#?secret=jRgGBg0bq9#?secret=EfCdNX6V8K\" data-secret=\"EfCdNX6V8K\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"YT6r5LERhF\"><a href=\"https:\/\/www.devopssupport.in\/blog\/type-null-is-not-a-subtype-of-type-string-errors\/\">&#8216;type &#8216;Null&#8217; is not a subtype of type &#8216;String&#8217; Errors<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;&#8216;type &#8216;Null&#8217; is not a subtype of type &#8216;String&#8217; Errors&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/type-null-is-not-a-subtype-of-type-string-errors\/embed\/#?secret=RpFGUoeLB1#?secret=YT6r5LERhF\" data-secret=\"YT6r5LERhF\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"KRAtGubnuS\"><a href=\"https:\/\/www.devopssupport.in\/blog\/building-elegant-multiple-select-dropdown-lists-in-flutter\/\">Building Elegant Multiple Select Dropdown Lists in Flutter<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Building Elegant Multiple Select Dropdown Lists in Flutter&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/building-elegant-multiple-select-dropdown-lists-in-flutter\/embed\/#?secret=YbrgvrASAv#?secret=KRAtGubnuS\" data-secret=\"KRAtGubnuS\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-devops-support wp-block-embed-devops-support\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"sdn19yrThw\"><a href=\"https:\/\/www.devopssupport.in\/blog\/platformexception-read_external_storage_denied-in-flutter\/\">PlatformException: read_external_storage_denied in Flutter<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;PlatformException: read_external_storage_denied in Flutter&#8221; &#8212; DevOps Support\" src=\"https:\/\/www.devopssupport.in\/blog\/platformexception-read_external_storage_denied-in-flutter\/embed\/#?secret=tQ7aj4ffEm#?secret=sdn19yrThw\" data-secret=\"sdn19yrThw\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The error message SQLSTATE[42S02]: Base table or view not found: 1146 indicates that Laravel is trying to access a database table called sessions that doesn\u2019t seem to&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1612,1599],"tags":[],"class_list":["post-2220","post","type-post","status-publish","format-standard","hentry","category-laravel-tutorial","category-php-tutorial"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/2220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=2220"}],"version-history":[{"count":2,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/2220\/revisions"}],"predecessor-version":[{"id":2273,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/2220\/revisions\/2273"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=2220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=2220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=2220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}