Wednesday, 26 July 2023

create database,replication and user in ubuntu mysql

RE


sudo mysql 


CREATE DATABASE master_db CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE DATABASE slave_db CHARACTER SET utf8 COLLATE utf8_general_ci;


CREATE USER 'test'@'localhost' IDENTIFIED BY 'your_password';



GRANT ALL PRIVILEGES ON master_db.* TO 'test'@'%';


GRANT ALL PRIVILEGES ON slave_db.* TO 'test'@'%';

FLUSH PRIVILEGES;


CREATE USER 'replication_user'@'localhost' IDENTIFIED BY 'your_password';

GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'localhost';



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


[mysqld]

pid-file        = /var/run/mysqld/mysqld.pid

socket          = /var/run/mysqld/mysqld.sock

datadir         = /var/lib/mysql

log-error       = /var/log/mysql/error.log

# By default we only accept connections from localhost

#bind-address   = 127.0.0.1

bind-address   = 0.0.0.0

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

#replica test

server-id = 1

log-bin = /var/lib/mysql/mysql-bin

report-host=master-is-slave-host

relay-log=myserver-relaylog

replicate-same-server-id=1

binlog-do-db=master_db

replicate-rewrite-db=master_db->slave_db

replicate-do-db=slave_db

sudo systemctl restart mysql


CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='replication_user', MASTER_PASSWORD='your_password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=0;

START SLAVE;


Tuesday, 25 July 2023

show all mysql users

sudo mysql 


SELECT User, Host FROM mysql.user;

python env error

 


python3 -m venv testenv Error: [Errno 13] Permission denied: '/home/testreader/apps/test/testenv/pyvenv.cfg' solution python3 -m venv ~/passenv

Monday, 24 July 2023

avoid asking password for sudo ubuntu

 sudo visudo

%sudo   ALL=(ALL:ALL) ALL
username ALL=(ALL) NOPASSWD: ALL
sudo ls


Poem aymen

 Aymen, a name that rings like a bell, A person of character, with stories to tell. With a heart full of kindness and a mind sharp and brigh...