MySQL常用命令(备忘)

$ mysqladmin create databasename #创建数据库

$ mysqladmin drop databasename #删除数据库

$ mysqldump databasename > databasename.sql #备份数据库到文件

mysql > use databasename;
mysql > source /the/sql/dir/databasename.sql; #从备份导入输入数据库

mysql >   GRANT ALL PRIVILEGES ON databasename.*  TO ‘dbuser’@’localhost’ IDENTIFIED BY ‘dbpassword’ WITH GRANT OPTION; #将数据库所有权限给用户dbuser,密码为dbpassword

字符问题:

 mysql> SHOW VARIABLES LIKE ‘character%’;
+————————–+—————————-+
| Variable_name            | Value                      |
+————————–+—————————-+
| character_set_client     | latin1                     |
| character_set_connection | latin1                     |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | latin1                     |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.00 sec)

在my.cnf中的[mysqld]和[client]中添加如下内容,统统改为UTF-8:

[mysqld]
default-character-set=utf8

[client]
default-character-set=utf8

发表回复