MySQL mysqldump相关

参考:

# mysql -u root -p
           
# 允许本地 IP 访问 localhost, 127.0.0.1
           
# insert into mysql.user(Host,User,Password) values('localhost','zhouz',password('1234'));
           
# 允许外网 IP 访问
           
# insert into mysql.user(Host,User,Password) values('%','zhouz',password('1234'));
           
# 刷新授权
           
# flush privileges;
           
# 创建数据库
           
# create database zhouzdb DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
           
# 授予用户通过外网IP对于该数据库的全部权限
           
# grant all privileges on `zhouzdb`.* to 'zhouz'@'%' identified by '1234';
           
# 授予用户在本地服务器对该数据库的全部权限
           
# grant all privileges on `zhouzdb`.* to 'zhouz'@'localhost' identified by '1234';
           
# 刷新权限
           
# flush privileges;
           
# 退出 root 重新登录
           
# \q
           
# 已新帐号 zhouz 登录,由于使用的是 % 任意IP连接,所以需要指定外部访问IP
           
# mysql -u zhouz -h 192.168.1.168 -p
           
# 1234

平时难得用下 mysql 的命令行模式操作,今天弄下新建用户授权,遇到些问题在这里简单整理下

注意: 若仅开放外网访问权限,则本地是无法访问的,需要本地服务器也能访问 mysql 则要增加本地访问权限

grant all privileges on `niu_bi_hong_hong`.* to 'niubi'@'%' identified by 'honghong';
 
grant all privileges on `niu_bi_hong_hong`.* to 'niubi'@'localhost' identified by 'honghong';
 
flush privileges

 

DB同步

#!/bin/bash
#for mysqldump&recover#
source /etc/profile
 
mysql -uroot -honghong-e "drop database  if exists niubi;"
mysql -uroot -honghong -e "drop database  if exists vip_member;"
mysql -uroot -honghong -e "create database  if not exists niubi default charset utf8;"
mysql -uroot -honghong -e "create database  if not exists vip_member default charset utf8;"
mysqldump -h123.206.33.33  -uroot -phoghong --compress --default-character-set=utf8 --single-transaction --databases service_platform \ 
vip_member | mysql -h123.206.33.33 -uroot -phonghong mysqldump -h33.3.3.33.33 -uroot -phonghong --compress --default-character-set=utf8 --single-transaction --databases kkk | mysql -uroot -phonghong

 

其他待续:

 

posted @ 2019-01-07 13:58  念槐聚  阅读(115)  评论(0)    收藏  举报