mysqldump

mysql常用命令

徘徊边缘 提交于 2019-12-24 18:22:11
一、连接MYSQL。 格式: mysql -h主机地址 -u用户名 -p用户密码 1、连接到本机上的MYSQL。 # mysql -u root -p 回车后提示你输密码,注意用户名前可以有空格也可以没有空格,但是密码前必须没有空格,否则让你重新输入密码。 如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中了,MYSQL的提示符是: mysql> 2、连接到远程主机上的MYSQL。假设远程主机的IP为:192.168.2.2,用户名为root,密码为123456。则键入以下命令: # mysql -h192.168.2.2 -uroot -p123456 3、退出MYSQL命令: # exit (回车) 二、修改密码。 格式:mysqladmin -u用户名 -p旧密码 password 新密码 1、给root加个密码123456。键入以下命令: # mysqladmin -u root -password 123456 2、再将root的密码改为56789。 # mysqladmin -u root -p123456 password 56789 三、增加新用户。 格式:grant select on 数据库.* to 用户名@登录主机 identified by “密码” 1、增加一个用户test1密码为abc,让他可以在任何主机上登录

Backup MySQL schema with foreign key table constraints

 ̄綄美尐妖づ 提交于 2019-12-24 08:57:29
问题 I created my MySQL schema that consists of multiple tables and I decided that I would add the foreign key constraints afterwards for each table, using the command: ALTER TABLE Orders ADD FOREIGN KEY (P_Id) REFERENCES Persons(P_Id) How can I get a backup of the schema (containing the foreign keys) so that I can duplicate it in another machine? Note that SHOW CREATE TABLE and mysqldump do not work in my case because they only create a UNIQUE KEY constraint and not a FOREIGN KEY. 回答1: mysqldump

mysqldump备份脚本

巧了我就是萌 提交于 2019-12-24 06:38:45
#!/bin/bash # 10 23 * * * /bin/bash /data/script/backup_mysqldump.sh BDATE=`date +%Y%m%d%H%M%S` BPATH=/data/backup LOGFILE=${BPATH}/log_${BDATE}.log mysqldump -uroot -pchengce243 -S /var/lib/mysql/mysql.sock trade_history -P3306 --single-transaction > ${BPATH}/trade_history_${BDATE}.sql echo > ${LOGFILE} for tfile in $(find $BPATH/ -mtime +7) do if [ -d $tfile ];then rm -rf $tfile elif [ -f $tfile ];then rm -rf $tfile fi echo -e "---- Delete backup file: $tfile ------" >> ${LOGFILE} done echo -e "\n====== Backup Jobs end at `date +%F' '%T' '%w` =====\n">> ${LOGFILE} 来源: https://www.cnblogs.com

MySQL InnoDB: cannot calculate statistics because the .ibd file is missing

左心房为你撑大大i 提交于 2019-12-24 00:58:36
问题 Environment: Windows 7 (XAMPP latest) Apache 2.4.4 PHP 5.5 MySQL 5.6.11 I am trying to backup a database from MySQL 5.1 and import it to MySQL 5.6. In MySQL 5.1, there are some MyISAM and InnoDB tables. I use mysqldump to dump the SQL file out, with --add-drop-database switch. Now when I go back to my localhost and import the SQL file using MySQL workbench, an error occur: InnoDB: cannot calculate statistics for table "database"."tables" because the .ibd file is missing. I tried drop the

Mysqldump create empty sql file? [php & mysql on Windows]

女生的网名这么多〃 提交于 2019-12-24 00:40:05
问题 I tried to dump a database: <?php $dbhost = "localhost"; $dbuser = "XXXX"; $dbpass = "XXXXXXXX"; $dbname = 'testdb'; $list = shell_exec ("C:\wamp\bin\mysql\mysql5.1.33\bin\mysqldump.exe $dbname --user=$dbuser--password=$dbpass > dumpfile.sql"); ?> I tried both specified full path to mysqldump.exe or just use mysqldump, it still give me a 0kb dumpfile.sql Details: Programming Language: PHP Database: MySql 5.XX OS(server): Windows Server 2003. (currently testing on Windows Vista machine) EDIT @

MySQL ENUM column won't match quoted values after import to new machine

不问归期 提交于 2019-12-23 22:21:04
问题 Recently I've imported a new database to develop on my local machine, however it doesn't work: the ENUM column only works when the variable is sent without quotation marks. Here's an example: mysql.local>select count(*) from psh_products where active = 1; +----------+ | count(*) | +----------+ | 72782 | +----------+ 1 row in set (0.04 sec) mysql.local>select count(*) from psh_products where active = '1'; +----------+ | count(*) | +----------+ | 0 | +----------+ 1 row in set (0.00 sec) In case

MYSQL备份与恢复精华篇

痴心易碎 提交于 2019-12-23 22:07:28
数据备份原理 数据备份属于数据容灾保护中的内容,所有的数据备份系统设计都基于这五个元素,备份源、备份目标、传输网络、备份引擎和备份策略。用户按照需要制定备份策略,使用定时任务执行备份脚本,使用备份引擎将需要备份的的数据从备份源通过传输网络传送到备份目标。 备份五元组: 1、 备份源 需要备份的数据统一称为备份源,可以是文本数据,音视频数据,也可以是数据库数据等等。 2、 备份目标 存放备份数据的位置,通常建议将备份数据存放在异机,或者是更远的数据中心,备份目标可以是在线的磁盘,磁盘阵列柜,也可以是磁带库或是虚拟带库。而备份目标所在的位置可以在同一个数据中心,也可以是容灾机房。 3、 传输网络 备份数据时使用的传输链路,可以是专线,以太网,Internet,VPN等等,只要保证备份源与目标之间的路由可达即可。 4、 备份引擎 数据要能够从源到目标流动,就要有动力,就像是水要流动一样,这个动力来源就是备份引擎,像mysqldump,nvbu,还有大量的备份软件都是备份引擎。 5、 备份策略 为了有效备份,并减少人为操作,应该制定完善的备份策略。通常全备与差备与增备相结合,备份的时间点应该尽量避开业务高锋期,通常在晚上执行,通过定时任务实现。 MYSQL 数据备份原理 mysql数据备份其实就是通过SQL语句的形式将数据DUMP出来,以文件的形式保存,而且导出的文件还是可编辑的

mysqldump returns code 6 when run from java, but the same command works fine from command line

自古美人都是妖i 提交于 2019-12-23 20:14:48
问题 When I run the same command from Java via Runtime.getRuntime I get the return code 6. The same command works fine from command line: process = Runtime.getRuntime().exec(mysqldumpCommand); int processComplete = process.waitFor(); For those 2 commands I get the return code 6 when run from java and no dump. The work fine from command line(I don't have a password on the local env.) mysqldump --user=root --password= --host=localhost dbname > c:\temp\dumpfile.sql mysqldump --user=root --password=""

How to selectively dump all innodb tables in a mysql database?

こ雲淡風輕ζ 提交于 2019-12-23 16:43:27
问题 I have a database called av2web, which contains 130 MyISAM tables and 20 innodb tables. I wanna take mysqldump of these 20 innodb tables, and export it to another database as MyISAM tables. Can you tell me a quicker way to achieve this? Thanks Pedro Alvarez Espinoza. 回答1: If this was an one-off operation I'd do: use DB; show table status name where engine='innodb'; and do a rectangular copy/paste from the Name column: +-----------+--------+---------+------------+- | Name | Engine | Version |

Can't delete a mySQL table. (Error 1050)

丶灬走出姿态 提交于 2019-12-23 12:42:55
问题 I have a pesky table that will not delete and it's holding up my dev environment refresh :( I know this table exists. Example... mysql> select * from uc_order_products_qty_vw limit 10; +-----+-------------+---------+---------+---------+---------+ | nid | order_count | avg_qty | sum_qty | max_qty | min_qty | +-----+-------------+---------+---------+---------+---------+ | 105 | 1 | 1.0000 | 1 | 1 | 1 | | 110 | 5 | 1.0000 | 5 | 1 | 1 | | 111 | 1 | 1.0000 | 1 | 1 | 1 | | 113 | 5 | 1.0000 | 5 | 1