mysqldump

mysql 导入导出数据库以及函数、存储过程

北战南征 提交于 2019-11-27 15:28:05
一、mysql常用导出数据命令 1.mysql导出整个数据库 mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql   mysqldump -hlocalhost -uroot hqgr> hqgr.sql (如果root用户没用密码可以不写-p,当然导出的sql文件你可以制定一个路径,未指定则存放在mysql的bin目录下) 2.mysql导出数据库一个表    mysqldump -hhostname -uusername -ppassword database tablename> 导出的文件名 mysqldump -hlocalhost -uroot hqgr t_ug_user> user.sql 3.mysql导出一个数据库结构    mysqldump -hhostname -uusername -ppassword -d --add-drop-table databasename > d:hqgrstructure.sql -d 没有数据 --add-drop-table 在每个create语句之前增加一个drop table 4.如果需要导出mysql里面的函数或者存储过程 mysqldump -hhostname -uusername -ppassword -ntd -R

Foreign key constraint error 1452 in MySQL - Magento import

别来无恙 提交于 2019-11-27 15:12:04
问题 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

mysqldump backup and restore to remote server

元气小坏坏 提交于 2019-11-27 14:48:59
问题 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 回答1: This link provides information on backing up and restoring with mysqldump. It also gives some examples with a

Mysql ERROR at line 1153: Unknown command '\'

烂漫一生 提交于 2019-11-27 14:06:50
问题 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

MySQL - mysqldump --routines to only export 1 stored procedure (by name) and not every routine

被刻印的时光 ゝ 提交于 2019-11-27 13:17:55
问题 So we have a lot of routines that come out from exporting. We often need to get these out in CLI, make changes, and bring them back in. Yes, some of these are managed by different folks and a better change control is required, but for now this is the situation. If I do: mysqldump --routines --no-create-info --no-data --no-create-db then great, I have 200 functions. I need to go through a file to find just the one or set I want. Is there anyway to mysqldump routines that I want like there is

mysqldump with db in a separate file

你离开我真会死。 提交于 2019-11-27 11:56:09
I'm writing a single line command that backups all databases into their respective names instead using of dumping all in one sql. Eg: db1 get saved to db1.sql and db2 gets saved to db2.sql So far, I'd gathered the following commands to retrieve all databases. mysql -uuname -ppwd -e 'show databases' | grep -v 'Database' I'm planning to pipe it with awk to do something like awk '{mysqldump -uuname -ppwd $1 > $1.sql}' But that doesn't work. I'm new to bash, so I could be wrong in my thinking. What should I do to make it export the db in their respective names? update: Ok, have to finally managed

linux下操作 mysql的基本命令

不羁的心 提交于 2019-11-27 11:47:01
1, 创建mysqld数据库的管理用户: 要把root用户设置为管理员,我们应该运行下面的命令; [root@linuxsir01 root]# mysqladmin -u root password 123456 一般情况下,mysqladmin所在目录已经加到$PATH中,如果该命令没有找到,查看软件包安装是否正确,确保Mysql-server和Mysql-client两个软件包都已经安装成功,然后可以rpm -qf Mysql-client查看该命令安装到那个目录中,将该目录加到$PATH变量中,或者-www.2cto.com-使用全路径。 需要注意的是,这里的root不是系统用户,而是数据库用户了。你也可以取别的用户名。 2, 登陆mysql数据库 以mysql数据库管理员root,密码为123456为例; [root@linuxsir01root]#/opt/mysql/bin/mysql -u root -p 如果找不到该命令,检查PATH变量,出现 Enter password:输入密码,回车。 然后出现: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.5.8 MySQL Community Server

mysqldump with create database line

三世轮回 提交于 2019-11-27 10:42:56
问题 I'm in the process of moving my files onto another computer, and one thing I would like to do is to transfer the data in my MySQL database. I want to dump the databases into .sql files, but also have the create database db_name including in the file, that way I just have to import the file to mysql without having to manually create the databases. Is there a way to do that? 回答1: By default mysqldump always creates the CREATE DATABASE IF NOT EXISTS db_name; statement at the beginning of the

Skip certain tables with mysqldump

五迷三道 提交于 2019-11-27 09:55:53
Is there a way to restrict certain tables from the mysqldump command? For example, I'd use the following syntax to dump only table1 and table2: mysqldump -u username -p database table1 table2 > database.sql But is there a similar way to dump all the tables except table1 and table2? I haven't found anything in the mysqldump documentation, so is brute-force (specifying all the table names) the only way to go? Paul Sheldrake You can use the --ignore-table option. So you could do mysqldump -u USERNAME -pPASSWORD DATABASE --ignore-table=DATABASE.table1 > database.sql There is no whitespace after -p

MySQL ERROR 1231 (42000):Variable 'character_set_client' can't be set to the value of 'NULL'

♀尐吖头ヾ 提交于 2019-11-27 09:52:52
问题 I've a MySQL 5.0.84 running in a Slackware 13.0 Staging server and wanted to copy a single table to another server which was built to use Ubuntu 14.04 OS for some other testing. I've taken a mysqldump of that table and copied to the testing server . I get the following error when I try to restore the dump file. ERROR 1231 (42000):Variable 'character_set_client' can't be set to the value of 'NULL' Please help me how to fix this error. Thanks! 回答1: I did some search in internet and fixed it