MySQL汉字字段按拼音排序和备份

本文介绍了MySQL数据库中的一些实用技巧,包括如何实现汉字字段按照拼音排序的方法、常用的数据库备份操作、导出数据或表结构的方式、创建及管理用户的各项操作等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

UTF-8编码的数据库,如果希望汉字字段按照拼音排序:

SELECT * FROM students ORDER BY CONVERT( name USING gbk ) ;

 原文地址:http://blog.youkuaiyun.com/stephenxu111/archive/2009/08/11/4436181.aspx

 

 

数据库备份:

 

#mysqldump最常用于备份一个整个的数据库:

shell> mysqldump -u username -p --opt db_name > backup-file.sql

#你可以这样将转储文件读回到服务器:

shell> mysql -u username -p db_name < backup-file.sql
 
 
创建用户:
 
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
  
为用户分配访问权限:
 
GRANT ALL ON database_name.* TO 'username'@'localhost';
 
查看用户权限:
 
show grants;
show grants for username;
show grants for username@localhost;
 
修改用户密码:
 
set password for username@’localhost’ = password(‘newpassword’); 
flush privileges;
取消用户授权:
 
revoke all on *.* from sss@localhost ;
 
删除用户:
 
use mysql
delete from user where user='name' and host='localhost' ;
flush privileges ;
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值