####监控脚本

[root@pdb~]# more /opt/VRTS/scripts/mysql_monitor.sh
#!/bin/sh
n=`ps -ef |grep mysql|grep "port=3306"|wc -l`
if test $n -eq 0
then exit 100
else exit 110
fi
[root@pdb~]# sh /opt/VRTS/scripts/mysql_monitor.sh

##############2 启动
[root@pdb~]# cd /opt/VRTS/scripts/mysql_monitor.sh

[root@pdb~]# cd /opt/VRTS/scripts
[root@pdbscripts]# ls
mysql_monitor.sh start_mysql.sh stop_mysql.sh

[root@pdbscripts]# more start*.sh
base=/oa/oas_mysql/app/mysql/
datadir=/oa/oas_mysql/data/mydata
config_file=/oa/oas_mysql/app/mysql/my.cnf
user=mysql
/oa/oas_mysql/app/mysql/bin/mysqld_safe --defaults-file=${config_file} --datadir=${datadir} --user=$user &

#########3 停止
[root@pdbscripts]# more stop*.sh
/oa/oas_mysql/app/mysql/bin/mysqladmin -uroot -pmysql shutdown

#############sample mysql  sample 导入和导出

############mysql 导入导出
https://www.cnblogs.com/smail-bao/p/6402265.html
CREATE DATABASE `db_monitor` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

赋予数据库(zqxt)权限给某用户,可以是已经存在的用户或新用户名
GRANT ALL PRIVILEGES ON zqxt.* TO "任意用户名"@"localhost" IDENTIFIED BY "新密码";

刷新权限
FLUSH PRIVILEGES;

退出数据库shell
EXIT;

1.备份单个数据库的数据和结构(,数据库名mydb)

mysqldump -uroot-p123456 db_monitor>c:\db_monitor.sql

2.还原单个数据库(需指定数据库)

(1) mysql>use mydb

mysql>source f:\mydb.sql

(2) mysql -uroot -p123456 mydb <c:\db_monitor.sql

# 输入密码开始导入数据

#######command

https://dev.mysql.com/doc/refman/8.0/en/testing-server.html
If you specify a database name, mysqlshow displays a list of the tables within the database:
shell> bin/mysql -e "SELECT User, Host, plugin FROM mysql.user" mysql
shell> bin/mysqlshow mysql

Use mysqladmin to verify that the server is running. The following commands provide simple tests to check whether the server is up and responding to connections:
shell> bin/mysqladmin version
shell> bin/mysqladmin variables

###############phpadmin连接远程数据库

phpadmin连接远程数据库
1、打开wampserver下phpmyadmin的目录在D:\wamp\apps\下 D:\wamp\apps\phpmyadmin4.1.14

2、找到config.inc.php文件,打开修改要连接的远程MySQL的host,user和password,更改这3个信息即可

其中必须保证数据库有被远程连接的权限

/* Authentication type */
$cfg['Servers'][$i]['verbose'] = 'mysql wampserver';
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'admin';
$cfg['Servers'][$i]['password'] = 'root';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '192.168.1.154';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

3.如果要用root登录此时也应该把host修改为localhost;

摘自http://blog.csdn.net/u010603691/article/details/50385409;

#######手工启停mysql

##section 1
10.241.95.221 (master)
##loging
su - mysql
mysql -P 3306 -uroot -pmysql

##with a non-default port
###mysql -S /mysql/mysql/data/mysqltmp/mysql_3307.sock -uroot -pmysql

##show master status
show master\G;

###shutdown db (with user mysql password mysql)
mysqladmin -uroot -p shutdown -S /mysql/mysql/data/mysqltmp/mysql.sock

###start db (with root)
/mysql/mysql/app/mysql/bin/mysqld_safe --defaults-file=/mysql/mysql/app/mysql/my.cnf &

##section 2

10.241.95.222 (slave)
###show slave staus
su - mysql
mysql -P 3306 -uroot -pmysql

##show slave status
show slave status\G;

mysql 启动停止脚本 and mysql 迁移 导入和导出的更多相关文章

  1. Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  2. Linux Oracle服务启动&停止脚本与开机自启动[转]

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  3. 【转】Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设置相关参数,首先先介 ...

  4. Mysql启动找不到mysql.sock文件问题(Centos7)

    刚装完Mysql5.7,将Mysql添加到开机自启.reboot之后mysql服务却没启动起来, 直接输入mysql –uroot –p ,出现如下错误,找不到mysql.sock文件.用servic ...

  5. redis 启动停止脚本

    redis 启动停止脚本,该redis需要密码登录,如没有密码,去掉stop函数里的 -a #!/bin/sh # #chkconfig: 2345 80 90 # Simple Redis init ...

  6. (转)Linux Oracle服务启动&停止脚本与开机自启动

    在CentOS 6.3下安装完Oracle 10g R2,重开机之后,你会发现Oracle没有自行启动,这是正常的,因为在Linux下安装Oracle的确不会自行启动,必须要自行设定相关参数,首先先介 ...

  7. SpringBoot项目快速启动停止脚本

    SpringBoot项目快速启动停止脚本 1.在jar包同级目录下,创建 app.sh #!/bin/bash appName=`ls|grep .jar$` if [ -z $appName ] t ...

  8. ubuntu上安装 MySQL 启动/停止 连接MySQL

    1.Ubuntu上安装MySQL服务   1.安装服务端   sudo apt-get install mysql-server    2.安装客户端   sudo apt-get install m ...

  9. mysql 启动 && 停止

    启动:service mysql start关闭:service mysql stop查进程:ps aux | grep mysql杀进程:kill -9 mysqlID Good Good Stud ...

随机推荐

  1. redis数据

    毫无疑问,Redis开创了一种新的数据存储思路,使用Redis,我们不用在面对功能单调的数据库时,把精力放在如何把大象放进冰箱这样的问题上,而是利用Redis灵活多变的数据结构和数据操作,为不同的大象 ...

  2. 解决 sublime text3 运行python文件无法input的问题

    怎么输入都没有用,原来需要配置可交互环境来运行 首先,Ctrl+Shift+p快捷键,弹出框框输入 install Package,回车后又弹出一个框,输入SublimeREPL(要安装的插件名字), ...

  3. js动态加载activeX控件在IE11与低版本IE中的差异

    由于IE11更加遵循W3C规范,所以IE11与低版本IE在加载activeX时有差别. 1.IE11中动态加载activeX的顺序 var objectTag = document.createEle ...

  4. BZOJ3196:二逼平衡树

    浅谈树状数组与线段树:https://www.cnblogs.com/AKMer/p/9946944.html 浅谈\(Splay\):https://www.cnblogs.com/AKMer/p/ ...

  5. The specified named connection is either not found in the configuration, not intended to be used

    今天用EF遇到一个问题, The specified named connection is either not found in the configuration, not intended t ...

  6. ABP启动流程分析

    添加服务与注册中间件 public IServiceProvider ConfigureServices(IServiceCollection services) { // Configure Abp ...

  7. 关于REST的一些想法

    REST and RESTful 最近入手了REST,谈谈自己的体会. 所谓REST, 我觉得是一种网址的设计风格.过去我们用Struts 或Spring MVC 时从来没有考虑过URL的设计风格.所 ...

  8. 正则表达式&nbsp;LINUX

    正则表达式 热身 正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串.将匹配的子串做替换或者从某个串中取出符合某个条件的子串等. 例如 g ...

  9. CodeForces - 828C String Reconstruction 并查集(next跳)

    String Reconstruction Ivan had string s consisting of small English letters. However, his friend Jul ...

  10. HDU - 6081 2017百度之星资格赛 度度熊的王国战略

    度度熊的王国战略  Accepts: 644  Submissions: 5880  Time Limit: 40000/20000 MS (Java/Others)  Memory Limit: 3 ...