mysql 启动停止脚本 and mysql 迁移 导入和导出
####监控脚本
[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索引总结(4)-MySQL索引失效的几种情况
- (转)Amoeba for MySQL 非常好用的mysql集群软件
- MySQL存储过程详解 mysql 存储过程
- 【mysql+pandas】用MySQL命令处理在python中处理DataFrame数据 pandasql库
- CentOS7 正确安装mysql(亲测)
- mysql启动时报错:Starting MySQL... ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.pid) 的解决方法
- koa 项目中引入 mysql
- Mac Docker 安装MySQL
- Mysql错误check the manual that corresponds to your MySQL server version for the right syntax
- Mac OS 下安装mysql环境
- 【mysql问题】解决2003-Can‘t connect to MySQL server on ‘ ‘(10060“Unknown error“)
- .NET/Mysql-petatoco连接mysql数据库
- 基于Python+Mysql实现(WinForm)书店销售管理管理子系统【100010028】
- Oracle不足与MySQL优势
- MySQL安全模式:sql_safe_updates讲解
- Mysql 5.7源码编译启动 报error问题:The server quit without updating PID file (/data/data_mysql/mysql.pid).
- MySQL运维之---mysqldump备份、select...into outfile、mysql -e 等工具的使用
- Mysql命令mysql:连接Mysql数据库
- Ubuntu下MySQL数据库文件 物理迁移后 出现的问题
- MySQL连接失败:10061错误,Can't connect to MySQL server on '127.0.0.1' (10061) (2003)
- Mysql Cluster节点类型(转载)
- mysql Access denied for user 'root'@'localhost' (using password: YES)
- Starting MySQL. ERROR! The server quit without updating PID file(xxx/x.pid)
- (5.4)mysql高可用系列——MySQL异步复制(实践)
- (1.5)MySQL表的5种分区类型
- 【曹工杂谈】Mysql-Connector-Java时区问题的一点理解--写入数据库的时间总是晚13小时问题