当前位置:网站首页>mysql常用命令以及mysqldump备份
mysql常用命令以及mysqldump备份
2022-07-30 05:48:00 【风云不语】
一、字符集
1.创建默认字符集的数据库
create database if not exists databaseName default charset utf8 collate utf8_general_ci;
2.字符集默认配置
[client]
default-character-set=utf8
/*[mysqld]*/
character-set-server=utf8
3.查看表字符集
show create table tableName;
4.修改单个表字符集
ALTER TABLE `table` DEFAULT CHARACTER SET utf8;
5.修改表字段记录字符集(表格已经插入数据)
alter table `tablename` convert to character set utf8;
6.创建表设置字符集
create table user(
id int not null auto_increment,
userName varchar(200) not null,
password varchar(200) not null,
age int,
primary key(id)
)ENGINE=MyISAM auto_increment=1 default charset=utf8;
二、数据库连接以及备份
1.mysql客户端无法远程连接
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%'IDENTIFIED BY 'password' WITH GRANT OPTION;
2.备份命令
格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 > 文件名.sql
mysqldump -h 192.168.1.1 -p 3306 -uroot -ppassword --databases mydb> /data/backup/mydb.sql
3.备份数据库结构,不备份数据
mysqldump --opt -d 数据库名 -u root -p > xxx.sql
4.导出数据不导出结构
mysqldump -t 数据库名 (表名) -uroot -p > xxx.sql
5.导出特定表的结构
mysqldump -uroot -p -B 数据库名 --table 表名 > xxx.sql
6.导入数据
#mysql 数据库名 < 文件名
#source /tmp/xxx.sql
边栏推荐
猜你喜欢
随机推荐
Waterfall flow (custom layout implementation)
Alamofire源码分析 - POST请求
【Untitled】
Biotin-NH2|CAS:111790-37-5(生物素-氨基)是一种生物素化化合物
IO进程线程->文件IO->day2
独立按键控制led进阶(1)
Comparison of advantages and disadvantages of VsCode and Sublime editors
SQL并列排序问题
测试第一题
JSP自定义标签
How to save modelsim simulation data as a file
二、2队列
I can't hide it, I want to expose the bad things about cloud native
事件传递和响应者链条
ES6 syntax notes (ES6~ES11)
js advanced study notes (detailed)
数码管动态显示及模块化编程
BlockingQueue详细介绍
【无标题】
独立按键控制led









