目录说明
主目录
/usr/share/mysql (一些目录和配置文件样例)
命令目录
/usr/bin (如mysql、mysqladmin、mysqldump)
数据文件目录
/var/lib/mysql/
启动停止
/etc/rc.d/init.d/mysql
启动
/etc/init.d/mysql start
停止
/etc/init.d/mysql stop
自动启动:
查看mysql是否在自动启动列表中 /sbin/chkconfig --list
把MySQL添加到你系统的启动服务组里面去 /sbin/chkconfig --add mysql
把MySQL从启动服务组里面删除 /sbin/chkconfig --del mysql
配置:
停止mysql
复制一个配置文件
[mysql@dev ~]$ sudo cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
设置编码方式
在[client]后加入
default-character-set=utf8 #设置客户端的字符编码
在[mysqld]后加入
default-character-set=utf8 #设置服务器端的字符编码 5.5的是character-set-server = utf8
lower_case_table_names=1 #设置表名不区分大小写
启动mysql
查看编码
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)
字符集参考
查看排序规则
mysql> show variables like '%collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
备份与恢复
备份
进入到库目录,cd /val/lib/mysql
mysqldump -u root -p --opt aaa > back_aaa恢复
mysql -u root -p ccc < back_aaa