skip to Main Content

Welcome

Say hello to the toggle bar. This is an optional section you can use to display any content you'd like. Simply select a page from the theme panel and the content of the page will display here. You can even use the drag and drop builder to create this! This is a perfect place for your company mission statement, alerts, notices or anything else.

Get In Touch

Email: support@total.com
Phone: 1-800-Total-Theme
Address: Las Vegas, Nevada

Our Location

Mysql命令大全

Mysql命令大全

用户相关操作

创建用户

create user ‘welk’@’%’ identified by ‘welk’;

查询所有用户

select user,host,password from mysql.user;

授权

grant all privileges on . to welk@’%’ identified by ‘welk’; flush privileges;

查看授权

show grants for ‘welk’;

修改密码

update mysql.user set password = password(‘welk’) where user = ‘welk’ and host = ‘%’; flush privileges; mysqladmin -u用户名 -p旧密码 password 新密码

删除用户

drop user zhangsan@’%’;

备份数据库 mysqldump

备份

备份命令mysqldump格式

mysqldump -h主机名 -P端口 -u用户名 -p密码 –database 数据库名 > 文件名.sql

备份MySQL数据库为带删除表的格式

mysqldump –add-drop-table -uusername -ppassword databasename > backupfile.sql

直接将MySQL数据库压缩备份

mysqldump -hhostname -uusername -ppassword databasename | gzip > backupfile.sql.gz

同时备份多个MySQL数据库

mysqldump -hhostname -uusername -ppassword –-databases databasename1 databasename2 > multibackupfile.sql

仅备份份数据库结构

mysqldump –no-data –-databases databasename1 databasename2 > structurebackupfile.sql

备份服务器上所有数据库

mysqldump –-all-databases > allbackupfile.sql

还原

还原MySQL数据库的命令

mysql -hhostname -uusername -ppassword databasename < backupfile.sql

还原压缩的MySQL数据库

gunzip < backupfile.sql.gz | mysql -uusername -ppassword databasename

将数据库转移到新服务器

mysqldump -uusername -ppassword databasename | mysql –host=... -C databasename

导入数据库 source

mysql> source d:\test.sql

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top