一 安装数据库服务
mysqld --install mysqlxy
二 启动数据库
net start mysqlxy
三 查询版本号
mysql> select version();
+------------------+
| version() |
+------------------+
| 5.1.71-community |
+------------------+
1 row in set (0.05 sec) 四 查询用户
mysql> use mysql
mysql> select host,user,password from user;
+-----------+------+----------+
| host | user | password |
+-----------+------+----------+
| localhost | root | |
| 127.0.0.1 | root | |
| localhost | | |
+-----------+------+----------+
五 建立用户和建库
mysql> create database tytx character set gbk;
Query OK, 1 row affected (0.01 sec)
mysql> grant all on tytx.* to tytx@localhost identified by 'mysql';
Query OK, 0 rows affected (0.05 sec)
mysql> show create table student;
------------------------------------------------------------------------------+
| Table | Create Table
------------------------------------------------------------------------------+
| student | CREATE TABLE `student` (
`id` int(11) DEFAULT NULL,
`name` char(12) DEFAULT NULL,
`class` char(10) DEFAULT NULL,
`grade` char(2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk |
+---------+-------------------------------------------------------------------------
这里可以看出所用的数据库引擎和字符集编码。
--查看表的状态
mysql> show table status from tytx where name='STUDENT';
六 备份
D:\>mysqldump -utytx -pmysql tytx >d:\mysql_2.dmp
这样备出来的是一个文本文件。可以压缩一下。
@echo on
cd d:\mysql\dmp\
del 15.sql.gz
move 14.sql.gz 15.sql.gz
move 13.sql.gz 14.sql.gz
move 12.sql.gz 13.sql.gz
move 11.sql.gz 12.sql.gz
move 10.sql.gz 11.sql.gz
move 9.sql.gz 10.sql.gz
move 8.sql.gz 9.sql.gz
move 7.sql.gz 8.sql.gz
move 6.sql.gz 7.sql.gz
move 5.sql.gz 6.sql.gz
move 4.sql.gz 5.sql.gz
move 3.sql.gz 4.sql.gz
move 2.sql.gz 3.sql.gz
move 1.sql.gz 2.sql.gz
set v_time=%date:~0,10%
set v_file=d:\mysqldmp\
mysqldump -utytx -pmysql tytx|gzip >1.sql.gz
还原
gunzip < 1.sql.gz | mysql -uusername -ppassword databasename