mysqldump

mysqldump with utf8 can not export the right emojis string

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: mysql 5.5.29, utf8mb4 charset, there is a table user containing a field nickname with value hex F09F988EF09F988E that is emojis ??. Now open mysql console, and execute: set names utf8mb4; select nickname, hex(nickname) from user; nickname | hex(nickname) ?? | F09F988EF09F988E and then execute mysqldump --default-character-set=utf8 -utest -ptest test_dev user > user.sql check the user.sql and find the nickname display ?? which hex string is 3f so, how can mysqldump with utf8 export the right emojis string? btw, the database charset

mysqldump error: Got packet bigger than max_allowed_packet'

社会主义新天地 提交于 2019-12-03 08:06:14
问题 My application download mails over IMAP and stores them in a MySQL database. Earlier I was supporting mails size upto 10 MB and hence a 'mediumtext' column to store the mail content was enough. Now I need to support mails upto 30MB. So I changed the datatype for the column to 'largetext'. Yesterday a mail with size 25 MB was stored. After that whenever I execute mysqldump command it throws error: mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `ib

day37

和自甴很熟 提交于 2019-12-03 07:30:44
目录 事务 特性 原子性 一致性 隔离性 持久性 存储引擎 视图 触发器 存储过程 函数 数据库备份 事务 事务指一组操作,要么都成功,要么都不成功 /* start transaction sql语句 commit(提交)/rollback(回滚到start之前的状态) 特性 原子性 原子意为最小的粒子,即不能再分的事务,要么全部执行,要么全部取消 一致性 指事务发生前和发生后,数据的总额依然匹配 隔离性 某个事务的操作对其他事务不可见 持久性 当事务完成后,其影响应当保留下来,不能撤销;只能通过“补偿性事务”抵消之前的错误 存储引擎 MyIsam:辣鸡 InnoDB:牛逼 create table user( id int auto_increment primary key, name varchar(255) not null default'' )engine=Innodb charset utf8; # mysql 5.5 以上默认Innodb #MyIsam 不支持事务,InnoDB支持事务 #MyIsam 支持表锁,InnoDB支持行锁 视图 -- create view 视图名 as SQL语句 #删除 drop view 视图名 -- 限制权限 grant select on 视图名 to 用户名 -- 所有权限 grant all privileges on

mysql面试题三

帅比萌擦擦* 提交于 2019-12-03 07:23:44
1、MySQL的复制原理以及流程 (1)、复制基本原理流程 1. 主:binlog线程——记录下所有改变了数据库数据的语句,放进master上的binlog中; 2. 从:io线程——在使用start slave 之后,负责从master上拉取 binlog 内容,放进 自己的relay log中; 3. 从:sql执行线程——执行relay log中的语句; (2)、MySQL复制的线程有几个及之间的关联 MySQL 的复制是基于如下 3 个线程的交互( 多线程复制里面应该是 4 类线程): 1. Master 上面的 binlog dump 线程,该线程负责将 master 的 binlog event 传到slave; 2. Slave 上面的 IO 线程,该线程负责接收 Master 传过来的 binlog,并写入 relay log; 3. Slave 上面的 SQL 线程,该线程负责读取 relay log 并执行; 4. 如果是多线程复制,无论是 5.6 库级别的假多线程还是 MariaDB 或者 5.7 的真正的多线程复制, SQL 线程只做 coordinator,只负责把 relay log 中的 binlog读出来然后交给 worker 线程, woker 线程负责具体 binlog event 的执行; (3)

Can I get a dump of all my databases *except one* using mysqldump?

北城以北 提交于 2019-12-03 06:30:47
问题 I'm currently using mySQLdump to backup my dev machine and servers. There is one project I just started, however, that has a HUUUUUGE database that I don't really need backed up, and i'll be a big problem to add it to the rest of the backup cycle. I'm currently doing this: "c:\Program Files\mysql\MySQL Server 5.1\bin\mysqldump" -u root -pxxxxxx --all-databases > g:\backups\MySQL\mysqlbackup.sql Is it possible to somehow specify "except this database(s)"? I wouldn't like to have to specify the

skip-lock-tables and mysqldump

无人久伴 提交于 2019-12-03 06:09:11
Daily we run mysql dumps on about 50 individual databases, package them up and then store them offsite. Some of these databases are rather large and contain myisam tables (which CANNOT be changed so suggesting it is pointless).. I have been reading up on using the skip-lock-tables option when doing a dump but have not read what the downside would be. All I see are basically different iterations of "it could have adverse effects if data is inserted to a table while it is dumping." What are these adverse effects? Does it just mean we will miss those queries upon a restore or will it mean the

Mysqldump more than one table?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 05:57:09
问题 How can I use mysqldump to dump certain tables that start with common prefix? 回答1: Hehe, this is kind of a hack, but it works (using bash): mysqldump -u USER -p DATABASE $(mysql -u USER -p -D DATABASE -Bse "show tables like 'PREFIX%'") > /tmp/DATABASE.out Change the ALLCAPS words as needed. 回答2: You can create backup.sh script: BACKUP_DIR="/path/to/backups" DB_HOST="domain.com" DB_USER="user" DB_PASS="pass" PREFIX="phpbb" TMP_LIST = mysql --host=$DB_HOST --user=$DB_USER --password=$DB_PASS -e

mysql restore to different database

亡梦爱人 提交于 2019-12-03 05:46:05
问题 I back up my production database with the following command: mysqldump -u root --opt --skip-extended-insert --databases my_production_db The resulting dump file has the following lines near the top: CREATE DATABASE /*!32312 IF NOT EXISTS*/ `my_production_db` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `my_production_db `; In order to restore the database to a different destination ie. my_debvelopment_db I have to open the dump file and edit the bits where the database is named. Then I run:

Error (1142) SELECT command denied on session_variables table with mysqldump

隐身守侯 提交于 2019-12-03 05:00:27
When I try to run mysqldump -u dump -p myschema > dumpfile.sql I get this error message: mysqldump: Couldn't execute 'SHOW VARIABLES LIKE 'gtid\_mode'': SELECT command denied to user 'dump'@'localhost' for table 'session_variables' (1142) I found something about adding --set-gtid-purged=OFF for a similar error. But I'm not running the MySQL 5.6 version of mysqldump on an older MySQL database. However, when I try it, I get a new, yet similar, error: mysqldump: Couldn't execute 'SHOW VARIABLES LIKE 'ndbinfo\_version'': SELECT command denied to user 'dump'@'localhost' for table 'session_variables

day 37

余生颓废 提交于 2019-12-03 04:58:55
day 36 mysql 事务 01.事务 事务指一组操作,要么都执行成功,要么都执行失败 transaction start transaction; # 开启一个事务 # 对数据进行操作 commit; # 组合操作执行成功,提交修改结果 rollback; # 撤销本次事务操作 事物的特性(ACID); 原子性(Atomicity);原子意为最小的粒子,代表事务不能被分割,要么全部执行,要么全部取消(防止数据出错) 一致性(Consistency);指事物发生前后数据总额依然相同 隔离性(Isolation);再本次事务尚未提交之前,对数据的操作无法被其他操作获取到 持久性(Durability);事务操作完成后,其对数据的影响被保存下来,不能撤销,只能通过‘补偿性事务’来抵消之前的错误。 存储引擎; InnoDB;高效引擎,不写默认使用Innodb create table 表名( id int auto_increment primary key, 字段名 类型 约束性 , ...... )engine = Innodb charset utf8; MyIsam;低效引擎 区别; innodb支持事务,支持行锁,精度更高 myisam不支持事务,支持表锁 pass 02.了解性 视图;view 用于项目中存在大量重复性查询sql语句 视图是一个特殊的表