mysqldump

How to copy table between two models in Mysql workbench?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 06:24:14
问题 I am doing some databese thing, I need copy one table from one model to another, but i try many ways there no effect. Is there any way for doing this? 回答1: Your best option is probably to create a stripped down version of the model that contains the objects you want to carry over. Then open the target model and run File -> Include Model... . Select the stripped down source model and there you go. 回答2: If you just want to do a single table through the MySQL Workbench. In MySQL Workbench:

Create table if not exists from mysqldump

廉价感情. 提交于 2019-11-29 05:25:42
问题 I'm wondering if there is any way in mysqldump to add the appropriate create table option [IF NOT EXISTS]. Any ideas? 回答1: According to one source, mysqldump does not feature this option. You could use the --force option when importing the dump file back, where MySQL will ignore the errors generated from attempts to create duplicate tables. However note that with this method, other errors would be ignored as well. Otherwise, you can run your dump file through a script that would replace all

MySQLdump备份并发送邮件

人盡茶涼 提交于 2019-11-29 03:33:47
概述: 文档中使用smtp协议,利用QQ邮箱发送邮件,其中客户端授权码是在开启QQ邮箱smtp服务是官方给予的,所以要牢记!!! 1、配置smtp #Linux yum install -y mailx #修改配置文件 vi /etc/mail.rc #在末尾追加如下内容并保存 set from=xxxxxxx@qq.com #设置发件人 set smtp=smtp.qq.com #设置外部STMP服务器 set smtp-auth-user=xxxxxxx@qq.com #设置STMP用户名 set smtp-auth-password=xxxxxxx #客户端授权码 set smtp-auth=login #测试 echo "this is my test mail" | mail -s 'mail test' xxxxxxx@qq.com 2、建立备份目录 mkdir -p /home/mysql/data/backup/mysql chown mysql:mysql /home/mysql/data/backup/mysql 3、备份脚本 cd /home/mysql/data/backup/mysql chmod +x mysqldump.sh vi mysqldump.sh #!/bin/bash BACKUP_PATH=/home/mysql/data/backup

mysqldump with --where clause is not working

。_饼干妹妹 提交于 2019-11-29 02:39:18
问题 mysqldump -t -u root -p mytestdb mytable --where=datetime LIKE '2014-09%' This is what I am doing and it returns: mysqldump: Couldn't find table: "LIKE" I am trying to return all the rows where the column datetime is like 2014-09 meaning "all September rows". 回答1: You may need to use quotes: mysqldump -t -u root -p mytestdb mytable --where="datetime LIKE '2014-09%'" 回答2: Selecting dates using LIKE is not a good idea. I saw this method in one project. This causes huge DBMS load and slow system

How to include MySQL database schema on GitHub?

萝らか妹 提交于 2019-11-29 02:22:34
问题 Stackoverflow and MySQL-via-command-line n00b here, please be gentle! I've been looking around for answers to my question but could only find topics dealing with GitHubbing MySQL dumps (as in: data dumps) for collaboration or MySQL "version control" via GitHub, neither of which tells me what I want to know: How does one include MySQL database schemas/information on tables with PHP projects on GitHub? I want to share a PHP project on GitHub which relies on the existence of a MySQL database

mysqldump with multiple tables with or without where clause

独自空忆成欢 提交于 2019-11-29 02:10:59
I have a set of tables in my database that I have to take a dump ( :D ) of. My problem is I want to take some data from some tables that only date back certain days and would like to keep the remaining tables in tact. The query I came up with was something like: mysqldump -h<hostname> -u<username> -p <databasename> <table1> <table2> <table3> <table4> --where 'created > DATE_SUB(now(), INTERVAL 7 DAY)', <table5> --where 'created > DATE_SUB(now(), INTERVAL 7 DAY) --single-transaction --no-create-info | gzip > $(date +%Y-%m-%d-%H)-dump.sql.gz The trouble with the above code is that table1, table2

mysql导入导出命令

佐手、 提交于 2019-11-29 00:47:26
一、导出数据库用mysqldump命令(注意mysql的安装路径,即此命令的路径): 1、导出数据和表结构: mysqldump -u用户名 -p密码 数据库名 > 数据库名.sql #/usr/local/mysql/bin/ mysqldump -uroot -p abc > abc.sql 敲回车后会提示输入密码 2、只导出表结构 mysqldump -u用户名 -p密码 -d 数据库名 > 数据库名.sql #/usr/local/mysql/bin/ mysqldump -uroot -p -d abc > abc.sql 注:/usr/local/mysql/bin/ ---> mysql的data目录 二、导入数据库 1、首先建空数据库 mysql>create database abc; 2、导入数据库 方法一: (1)选择数据库 mysql>use abc; (2)设置数据库编码 mysql>set names utf8; (3)导入数据(注意sql文件的路径) mysql>source /home/abc/abc.sql; 方法二: mysql -u用户名 -p密码 数据库名 < 数据库名.sql #mysql -uabc_f -p abc < abc.sql 来源: https://www.cnblogs.com/sung1024/p/11437223

Foreign key constraint error 1452 in MySQL - Magento import

时光毁灭记忆、已成空白 提交于 2019-11-29 00:09:54
i am trying to import a sql dump of magento along with some product data and i get this foreign key constraint error: `ERROR 1452 (23000) at line 231680: Cannot add or update a child row: a foreign key constraint fails: `magento`.`#sql-b33_27`, CONSTRAINT `FK_CATALOG_COMPARE_ITEM_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON )` This is the sql code which is causing the error : -- -- Constraints for table `catalog_eav_attribute` -- ALTER TABLE `catalog_eav_attribute` ADD CONSTRAINT `FK_CATALOG_EAV_ATTRIBUTE

Mysql ERROR at line 1153: Unknown command '\\'

狂风中的少年 提交于 2019-11-28 23:40:31
I am trying to import a mysqldump file via the command line, but continue to get an error. I dumped the file from my other server using: mysqldump -u XXX -p database_name > database.sql Then I try to import the file with: mysql -u XXX -p database_name < database.sql It loads a small portion and then gets stuck. The error I receive is: ERROR at line 1153: Unknown command '\''. I checked that line in the file with: awk '{ if (NR==1153) print $0 }' database.sql >> line1153.sql and it happens to be over 1MB in size, just for that line. Any ideas what might be going on here? You have binary blobs

mysqldump backup and restore to remote server

女生的网名这么多〃 提交于 2019-11-28 23:29:29
How can i use mysqldump to backup and restore database to a remote server? Both have root access. I am using putty to perform this. So far I tried the following: mysqldump -u root -p >z*x311a!@ masdagn_joom15 | mysql \ -u root -p g2154hE6-AsXP --host=207.210.71.26 -C masdagn_joom15temp \g but it refused the local password is: >z*x311a!@ the remote password is: g2154hE6-AsXP NebuSoft This link provides information on backing up and restoring with mysqldump. It also gives some examples with a remote server. The important commands from that link being: backup: mysqldump -u root -p[root_password]