Saturday, July 8, 2023

Restore xampp database from backup

steps:

stop mysql xampp

1 - create some backup folder "data_1" 

2 - from your current xampp/mysql/data folder move core folders and all files (like 'mysql', 'performance_schema', 'phpmyadmin', 'test'  and all files to new backup folder

3 - from xampp/mysql/backup foder - move all to you xampp/mysql/data folder (so it is like override code folders/files from backup)

4 - from you beckup 'data_1' folder , copy file ibdata1 to /xampp/mysql/data folder

restart mysql


https://stackoverflow.com/questions/18022809/how-to-solve-error-mysql-shutdown-unexpectedly

Tuesday, October 8, 2019

mysql Index for table '.\mysql\user.MYI' is corrupt; try to repair it

Here is original source that worked for me

https://stackoverflow.com/questions/57128891/how-repair-corrupt-xampp-mysql-user-table

(1) Find 'my.ini' (eg. c:\xampp\mysql\bin\my.ini )
(2) Insert 'skip-grant-tables' in a new line following label '[mysqld]'. Remove this later.
(3) Now mySQL can be started from the XAMPP control panel.
(4) Start phpMyAdmin from browser and select table 'user' from database 'mysql'
(5) Should see: #1034 Index for table 'user' is corrupt; try to repair it.
(6) Select 'mysql' from left panel then check 'user' in right hand panel.
(7) From the 'With selected' dropdown run 'analyze' then 'repair table'.
(8) If 'Repair' fails no choice but to 'DROP TABLE user' ....
(9) Recreate 'user' table from the distribution backup by copying the following 3 files.
C:\xampp\mysql\backup\mysql\user.frm 
C:\xampp\mysql\backup\mysql\user.MYD
C:\xampp\mysql\backup\mysql\user.MYI
to
C:\xampp\mysql\data\mysql\
then restarting XAMPP and adding/removing/editing users as you wish.

One last point: There seems to be some sort of association between the 'user' and 'db' tables. You may need to repair the 'db' table as per step (7).

Monday, September 2, 2019

Laravel 4 php 7 Uncaught TypeError: Argument 1 passed to Illuminate\Exception\WhoopsDisplayer::display()

after upgrade php from 5 to 7, in laravel 4 there were problems with display of exceptions and errors.
Need to make such fixes in code laravel files:

Add this to Illuminate\Exception\Handle

inside method

public function handleException($exception)
{
if ( ! $exception instanceof Exception) { $exception = new ErrorException( $exception->getMessage(), $exception->getCode(), E_ERROR, $exception->getFile(), $exception->getLine() ); }

/////// original code here
}

Sunday, August 11, 2019

mysqli_real_connect(): (HY000/1130): Host 'localhost' is not allowed to connect to this MariaDB server

mysqli_real_connect(): (HY000/1130): Host 'localhost' is not allowed to connect to this MariaDB server

after fresh install of windows and install xampp I had problems with mysql

to fix connection I added row
skip-grant-tables
into [mysqld] section in my.ini file for mysql

it fixed connection issue, but were problems with privileges
something like:
Table 'user' is marked as crashed and should be repaired

so, to fix it. need to add this line
skip-grant-tables
into my.ini (and restart mysql)

then go to mysql (I used phpmyadmin) and execute commands:
USE mysql;
CHECK TABLE user;
REPAIR TABLE user;

it fixed privileges tables.
after this you can remove line
skip-grant-tables
from config file and reload mysql server.

source article:
https://forum.laragon.org/topic/801/host-localhost-is-not-allowed-to-connect-to-this-mariadb-server/6

Magento 2.3 does not work properly on localhost xampp on wondows

source from

https://magento.stackexchange.com/questions/251926/magento-2-3-its-not-working-properly-in-localhost
https://github.com/magento/magento2/issues/19480#issue-386162790

solution:

#/vendor/magento/framework/View/Element/Template/File/Validator.php:139

foreach ($directories as $directory) {
    // Add this line
    $realDirectory = $this->fileDriver->getRealPath($directory);

// this is fix
    $realPath = str_replace('\\', '/', $realPath);

    // and replace `$directory` with `$realDirectory`
    if (0 === strpos($realPath, $realDirectory)) {
        return true;
    }
}


///////////////
also try to redeploy content, like
php -f bin/magento setup:static-content:deploy

Tuesday, December 19, 2017

Magento 2 - install extension via composer shows memory limit error

Problem:

In Magento 2, when trying to install 3rd party extension via composer, like:
composer require vendor_name/module_name

server shows memory allocated error, like PHP Fatal error: Allowed memory size of xxxxx bytes exhausted

problem was that server is configured to php70 and even increase of memory in pgp.ini does not help,

Solution:
there is ability to run composer command via php, like:
php70 composer.phar require vendor_name/module_name

If it will say something like: could not open input file composer.phar
it means that it is not installed or something, so try to install it by command
curl -sS https://getcomposer.org/installer | php
it will place composer.phar file right in curent folder
after this, you can try to execute command like:

php composer.phar require vendor_name/module_name
to change memory limit execute like
php -d memory_limit=2G composer.phar require vendor/module

also, try to skip requirements like
composer require vendor/module --ignore-platform-reqs


Friday, September 22, 2017

Magento 1: How to override Paypal Model in your custom module

Task: Need to overrite magento paypal model method in your custom module

Solution:
For example, need to override /app/code/core/Mage/Paypal/Model/Config.php  method getBuildNotationCode

Create model in your extantion

app/code/local/YourFirm/ExtName/Model/Paypal/Config.php

code:

class YourFirm_ExtName_Model_Paypal_Config extends Mage_Paypal_Model_Config
{
    public function getBuildNotationCode($countryCode = null)
    {
        ... your code here....
       // if you need, you could run base function, use: parent::getBuildNotationCode($countryCode);
    }
}


open confix.xml in your extantion
/app/code/local/YourFirm/ExtName/etc/config.xml

and add next code in global section:

and add next code in global section:
    <global>
        <models>
            <paypal>
             <rewrite>
              <config>YourFirm_ExtName_Model_Paypal_Config</config>
             </rewrite>
            </paypal>            
        </models>
    </global>

           
           
                  

Restore xampp database from backup

steps: stop mysql xampp 1 - create some backup folder "data_1"  2 - from your current xampp/mysql/data folder move core folders an...