1.修改密码:
1
|
格式:mysqladmin
-u用户名 -p旧密码 password 新密码 |
2.备份还原数据库:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
设置从特定地址的服务器导出数据,
缺省主机是localhost, 则设置参数 -h
或 --host= 备份所有数据库: mysqldump
-u root -p123 --all-database
> test.sql 备份数据库test mysqldump
-u root -p123 test > test.sql 备份数据库test下的 temp 表: mysqldump
-u root -p123 test demp > test.sql 还原数据库test mysqldump
-u root -p123 test < test.sql 还原数据库test下的 temp 表: mysqldump
-u root -p123 test demp < test.sql 但是有时候这样还原不了,那就进入mysql控制台,使用命令: source
test.sql |
3.权限设置:
1
2
3
4
5
6
|
#授权 grant all on dbname.* to 'username' @ '192.168.0.10' identified by 'passwd' ; #删除权限 revoke all on dbname.* from 'username' @ '192.168.0.10' identified by 'passwd' ; #刷新权限 FLUSH PRIVILEGES ; |
4.mysql 设置编码:
1
2
3
4
5
|
set character_set_client=utf8; set character_set_connection=utf8; set character_set_database=utf8; set character_set_results=utf8; set character_set_server=utf8; |
数据库及表转换成utf编码
1
2
3
4
5
|
#转换 alter table table_name convert to character set utf8; #和上面的不同,这个应该是设置编码 alter database database_name character set utf8; alter table table_name character set utf8; |
创建时指定编码:
1
2
3
4
5
6
7
8
9
10
11
|
创建数据库 ## create database name character set utf8; UTF8: CREATE DATABASE 'test2' DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci 创建表 CREATE TABLE 'type' ( `id` int (10)
unsigned NOT NULL auto_increment, `flag_deleted`
enum( 'Y' , 'N' ) character set utf8 NOT NULL default 'N' , `flag_type` int (5) NOT NULL default '0' , `type_name` varchar (50) character set utf8 NOT NULL default '' , PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; |
查看字符编码:
1
2
|
SHOW
VARIABLES LIKE 'character_set_%' ; SHOW
VARIABLES LIKE 'collation_%' ; |
数据库设置:
1
2
3
4
5
|
#找到客户端配置[client]
在下面添加 default - character - set =utf8
#默认字符集为utf8 #在找到[mysqld]
添加 character - set -server=utf8
#默认字符集为utf8 init- connect = 'SET
NAMES utf8' #(设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)
|