Thursday, March 25, 2021

Grant Single DB to MYSQL User

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'%';


FLUSH PRIVILEGES;

Sunday, March 21, 2021

Apache permission denied (Ubuntu)

[Mon Mar 22 06:43:51.067590 2021] [core:error] [pid 25490] (13)Permission denied: [client 27.109.115.156:55380] AH00035: access to /pssusermanipulation/ denied (filesystem path '/var/www/api/folder/folder') because search permissions are missing on a component of the path 


Solution: chmod a+rX -R /var/www

Configure Django with Apache

Python2

sudo apt-get install python-pip apache2 libapache2-mod-wsgi

Python3

sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3 

<VirtualHost *:80>

        ServerName abc.com

        ServerAlias abc.com

        Alias /static /var/www/api/env/lib/python3.6/site-packages/django/contrib/admin/static

        <Directory /var/www/api/folder/folder >

                <Files wsgi.py>

                        Require all granted

                </Files>

        </Directory>


        WSGIDaemonProcess tigergourd python-path=/var/www/folder/folder python-home=/var/www/api/env

        WSGIProcessGroup groupname

        WSGIScriptAlias / /var/www/api/folder/folder/wsgi.py


</VirtualHost>


-- In case error when run manage.py-----


mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

pip install mysql-connector-python




Running setup.py clean for Pillow

  Building wheel for pycrypto 

  

  pip uninstall pycrypto

  pip install pycryptodome


Thursday, March 18, 2021

MySQL: Necessary Command

sudo service mysql status

sudo service mysql restart

sudo mysql_secure_installation


—-- Disable root password

Sudo /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]

skip-grant-tables


———— Setup Mysql 

sudo apt update

sudo apt install mysql-server

sudo mysql_secure_installation


--- Remove MySQL 

sudo apt purge mysql-server mysql-common

sudo apt autoremove mysql-server mysql-common


— Grant remote permission to user

GRANT ALL PRIVILEGES on *.* to root@'%' identified by ‘password’;

FLUSH PRIVILEGES;

MySQLDump


Bakup table structure and data

mysqldump -u root -p[password] [database_name] > dumpfilename.sql

Bakup table structure 

mysqldumpd -u root -p[password] [database_name] > dumpfilename.sql


 

Wednesday, March 17, 2021

Restore Digital Ocean Snapshot(Ubuntu) has an error MYSQL Service

The following packages have unmet dependencies:

 linux-image-4.4.0-177-generic : Depends: linux-modules-4.4.0-177-generic but it is not going to be installed


 mysql-client-5.7 : Depends: mysql-common (>= 5.5) but it is not going to be installed

 mysql-server-5.7 : PreDepends: mysql-common (>= 5.5) but it is not going to be installed

                    Depends: mysql-common (>= 5.6.22-1~) but it is not going to be installed

E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).


1- Install header file by using this command: apt-get -f install

2- Backup MySql database

3- Remove MySql database 

4- Reinstall MySql database

5- Restore MySql database



Back Up Mysql Data When its Service Dump (Ubuntu)

 1- Backup /var/lib/mysql to other location

2- Reinstalling MySQL may solve the problem, but should only be used as a last resort! To reinstall:

sudo apt purge mysql-server mysql-common

sudo apt autoremove mysql-server mysql-common

and reinstall it again

sudo apt-get update sudo apt-get install mysql-server


3- copy backup to /var/lib/mysql 


or in case it is not override old database  please reverse backup



Create Bash Script to Check if MySQL is Running

 #!/bin/bash


# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1

# Restart the MySQL service if it's not running.
if [ $? != 0 ]; then
    sudo service mysql restart
fi

Run this script every 5 minutes using a cron job like this one:

 */5 * * * * /home/user/scripts/monitor.sh > /dev/null 2>&1

Tuesday, March 16, 2021

Create Snapshot Ubuntu OS

 

Ubuntu-based Distributions

Ubuntu, Linux Mint, Elementary OS, etc.

Packages are available in the Launchpad PPA for supported Ubuntu releases. Run the following commands in a terminal window:

sudo add-apt-repository -y ppa:teejee2008/timeshift
sudo apt-get update
sudo apt-get install timeshift

https://github.com/teejee2008/timeshift

Friday, March 12, 2021

Flutter: Enable Flutter Outline view in Adroid Studio

 

  1. Android Studio > Preferences > Languages & Frameworks > Flutter > App Execution > Open Flutter Inspector view on launch.
  2. Close and Relaunch Android Studio > Open any Flutter Project > Open iOS Simulator or Android Emulator and Run Debug Mode.

Flutter: Configure Web Firebase

<script src="https://www.gstatic.com/firebasejs/8.3.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.3.0/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.3.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.3.0/firebase-auth.js"></script>

<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "AIzaSyBMrhRJqdZBjqgOMjw-2lcsiIAyA5na3VU",
authDomain: "fir-project-e1016.firebaseapp.com",
databaseURL: "https://fir-project-e1016-default-rtdb.firebaseio.com",
projectId: "fir-project-e1016",
storageBucket: "fir-project-e1016.appspot.com",
messagingSenderId: "65139327059",
appId: "1:65139327059:web:1a6472ddc7655c174d46a6",
measurementId: "G-LH4D913KNT"
};
// Initialize Firebase

firebase.initializeApp(firebaseConfig);
firebase.analytics();
firebase.firestore();
</script>

Flutter: Running with unsound null safety

 

Update pubspec.yaml

analyzer:

  enable-experiment:
- non-nullable

environment:
sdk: '>=2.12.0 <3.0.0'

Thursday, March 11, 2021

Configure Apache Virtual Host SSL & Virtual Host None SSL

 <VirtualHost *:443>

        ServerName xxx.com

        ServerAlias www.xxx.com


        DocumentRoot /var/www/xxx.com


        SSLEngine on

        SSLCertificateFile /etc/ssl/certs/xxx.crt

        SSLCertificateKeyFile /etc/ssl/private/xxx.key


    <Directory /var/www/ktechglobe.com>

        Options Indexes FollowSymLinks MultiViews

        AllowOverride All

        Require all granted

    </Directory>


        ErrorLog ${APACHE_LOG_DIR}/error.log

        CustomLog ${APACHE_LOG_DIR}/access.log combined



</VirtualHost>


<VirtualHost *:80>


        ServerName xxx.com

        ServerAlias www.xxx.com

        #ServerAdmin webmaster@localhost

        DocumentRoot /var/www/xxx.com

        #Redirect permanent / https://www.xxx.com/

    <Directory /var/www/ktechglobe.com>

        Options Indexes FollowSymLinks MultiViews

        AllowOverride All

        Require all granted

    </Directory>



        ErrorLog ${APACHE_LOG_DIR}/error.log

        CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>

Monday, March 8, 2021

Flutter: d8: cannot fit requested classes in a single dex file

Solution to fixed: d8-cannot-fit-requested-classes-in-a-single-dex-file 

android {

    defaultConfig {
        ...
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}