First steps
mysql_secure_installation
Passwordpress login mysql
create ~/.my.cnf with
[client]
password=plaintextpassword
user=root
Create Database
long variant ;
create database testdb;
create user ‘testuser’@’localhost’ identified by ‘password’;
grant all on testdb.* to ‘testuser’ identified by ‘password’;
short one :
create database testdb;
grant all on testdb.* to ‘testuser’ identified by ‘password’;
Reset the MySQL Root Password
systemctl stop mysqld
mysqld_safe –skip-grant-tables &
mysql -u root
use mysql; update user SET PASSWORD=PASSWORD(“password”) WHERE USER=’root’; flush privileges; exit
systemctl start mysqld
Replication
Add in /etc/my.cnf in [mysqld]
—master—
server_id=1
log-basename=master
log-bin
binlog-format=row
binlog-do-db=$NAME-OF-DB-TO-REPLICATE
—slave—
server-id = 2
replicate-do-db=$NAME-OF-DB-TO-REPLICATE
mysql-master-sql
GRANT REPLICATION SLAVE ON *.* TO 'user'@'%' IDENTIFIED BY 'password';
start slave;
SHOW MASTER STATUS;
!!!!Position and File !!!
mysql-slave-sql
stop slave;
CHANGE MASTER TO MASTER_HOST=’IP8′, MASTER_USER=’user’, MASTER_PASSWORD=’password’, MASTER_LOG_FILE=’mariadb-bin.000005‘, MASTER_LOG_POS=245 ,MASTER_CONNECT_RETRY=5 ;
start slave;
SHOW SLAVE STATUS\G;