Mysql start - WBowam/wbowam.github.com GitHub Wiki
Date:2014-06-19
Title:Mysql语句入门(1)
Tags:Mysql
Category:It
mysql -u root -p
Enter password:
mysql> quit
mysql> CREATE DATABASE tulpar_db CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> GRANT ALL ON tulpar_db.* TO 'tulpar'@'localhost' IDENTIFIED BY 'mypassword';
mysql>use tulpar_db
mysql>source ../wcnc_db.sql
mysqldump -u 用户名 -p 数据库名 > 导出的文件名
mysqldump -u tulpar -p tulpar_db > tulpar_db.sql
show databases;
DROP DATABASE <databasename>;
use tulpar_db;
show tables;
DROP TABLE <tablename>;
我是通过sudo apt-get install mysql
来安装的。mysql的配置文件在/etc/mysql/my.cnf
如果找不到这个文件,可以运行sudo find / -iname ‘*.cnf’
查找所有的cnf文件
在[mysqld]下添加
default-character-set=utf8
在[client]下添加
default-character-set=utf8
sudo service mysql restart
mysql -u root
mysql> SHOW VARIABLES LIKE 'char%';
+--------------------------+----------------------------+
| Variable_name | VALUE |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | BINARY |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 ROWS IN SET (0.00 sec)
感觉还是挺麻烦的,注意要修改数据库、表、字段的编码。