『壹』 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
#
直接執行查詢語句