Wednesday, April 14, 2021

Create First Root User

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'PASSWORD';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

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