‘壹’ linux shell脚本执行mysql mysql数据库在远程服务器上
方法一、适合所有格式的mysql数据库,通过对数据库导出导进写个脚本定时执行:
1.导出整个数据库 mysqlmp -u 用户名 -p 数据库名 > 导出的文件名 mysqlmp -u wcnc -p smgp_apps_wcnc > /存放路径/wcnc.sql
2.导出一个表 mysqlmp -u 用户名 -p 数据库名 表名> 导出的文件名 mysqlmp -u wcnc -p smgp_apps_wcnc users> /存放路径/wcnc_users.sql
3.导出一个数据库结构 mysqlmp -u wcnc -p -d --add-drop-table smgp_apps_wcnc >/存放路径/wcnc_db.sql
定义:
-d 没有数据
--add-drop-table 在每个create语句之前增加一个drop table
4.导入数据库 常用source 命令 进入mysql数据库控制台:
如mysql -u root -p mysql>use 数据库
方法二、针对mysql数据表格式为MyISAM的
假如数据文件在/var/lib/mysql
那么直接写个脚本
cp -r /var/lib/mysql /备份到的文件夹路径
隔机备份用rsync增量,或定时完整备份。
‘贰’ linux系统mysql数据库怎么进入数据库
连接MYSQL:mysql -h主机地址 -u用户名 -p用户密码
‘叁’ 用虚拟机中的linux编写shell脚本操作主机的mysql数据库怎么实现
当然可以实现,只要网络可以连通,并且mysql允许外链就可以了。
‘肆’ 如何将xshell中的mysql导出查询 mp
如何将xshell中的mysql导出查询 mp
开始—运行—输入“CMD”回车,然后直接写入以下命令
导出的命令:
exp 用户名/密码@数据库名 file=D:\database.dmp log=data.log
file后是写得你导出的文件存放的路径,database.dmp是你导出的文件,log是你导出日志,便于查询错误,不要也可以。例如 exp user/password@orcl file=d:\aaa.dmp
‘伍’ 如何检查mysql数据库enforce
一、Introction
Sakila可以作为数据库设计的参考,也可作为实验数据。我是用作数据仓库和ODI学习的实验数据。
The Sakila sample database was developed by Mike Hillyer, a former member of the MySQL AB documentation team, and is intended to provide a standard schema that can be used for examples in books, tutorials, articles, samples, and so forth. Sakila sample database also serves to highlight the latest features of MySQL such as Views, Stored Proceres, and Triggers.
二、Installation
方法一:安装MySQL时选择 FULL 完全安装
安装MySQL时选择FULL 完全安装, 默认安装了Sakila sample database
clip_image002 clip_image004
方法二:下载后导入
The Sakila sample database is available from http://dev.mysql.com/doc/index-other.html. A downloadable archive is available in compressed file or Zip format. The archive contains three files: sakila-schema.sql, sakila-data.sql, and sakila.mwb.
The sakila-schema.sql file contains all the CREATE statements required to create the structure of the Sakila database including tables, views, stored proceres, and triggers.
The sakila-data.sql file contains the INSERT statements required to populate the structure created by the sakila-schema.sql file, along with definitions for triggers that must be created after the initial data load.
The sakila.mwb file is a MySQL Workbench data model that you can open within MySQL Workbench to examine the database structure. For more information, see MySQL Workbench.
解压后得到三个文件:
1. sakila-schema.sql 文件包含创建Sakila数据库的结构:表、视图、存储过程和触发器
2. sakila-data.sql文件包含:使用 INSERT语句填充数据及在初始数据加载后,必须创建的触发器的定义
3. sakila.mwb文件是一个MySQL Workbench数据模型,可以在MySQL的工作台打开查看数据库结构。
shell> mysql -u root -p
mysql> SOURCE C:/temp/sakila-db/sakila-schema.sql;
mysql> SOURCE C:/temp/sakila-db/sakila-data.sql;
查看导入结果
sakila
三、Structure
‘陆’ 如何用shell脚本实现mysql数据库的操作
用MYSQL命令切换进行MYSQL中,可以用SQL命令了。
‘柒’ 如何查看mysql数据库操作记录日志
是否启用了日志
1
mysql>show variables like 'log_bin';
怎样知道当前的日志
1
mysql> show master status;
看二进制日志文件用mysqlbinlog
shell>mysqlbinlog mail-bin.000001(要写绝对问题路径d://)
或者
shell>mysqlbinlog mail-bin.000001 | tail
Windows 下用类似的命令。
mysql有以下几种日志:
错误日志: -log-err
查询日志: -log
慢查询日志: -log-slow-queries
更新日志: -log-update
二进制日志:-log-bin在mysql的安装目录下,打开my.ini,在后面加上上面的参数,保存后重启mysql服务就行了。
‘捌’ shell脚本管理mysql
方法一、适合所有格式的mysql数据库,通过对数据库导出导进写个脚本定时执行:1.导出整个数据库mysqlmp-u用户名-p数据库名>导出的文件名mysqlmp-uwcnc-psmgp_apps_wcnc>/存放路径/wcnc.sql2.导出一个表mysqlmp-u用户名-p数据库名表名>导出的文件名mysqlmp-uwcnc-p◇mgp_apps_wcncusers>/存放路径/wcnc_users.sql3.导出一个数据库结构mysqlmp-uwcnc-p-d--add-drop-tablesmgp_apps_wcnc>/存放路径/wcnc_db.sql定义:-d没有数据--add-drop-table在每个create语句之前增加一个droptable4.导入数据库常用source命令进入mysql数据库控制台:如mysql-uroot-pmysql>use数据库方法二、针对mysql数据表格式为MyISAM的假如数据文件在/var/lib/mysql那么直接写个脚本cp-r/var/lib/mysql/备份到的文件夹路径隔机备份用rsync增量zd或定时完整备份951
这样可以么?
‘玖’ 如何在shell中操作mysql数据库
mysql
-u
username
-p
password
#
连接mysql服务
show
databases
#
查看所有数据库
use
dbname
#选择一个数据库
show
tables
#
查看数据中所有的表
select
*
from
tablename
#
直接执行查询语句