zoukankan      html  css  js  c++  java
  • mysql查看数据库命令

    mysql查看数据库命令

      打开的数据库的命令

      mysql> use mysql

      Database changed

      查看数据库的命令

      mysql> show databases;

      查看数据表的详细结构

      mysql> desc func;

      新建数据库

      mysql> create database school;

      Query OK, 1 row affected (0.00 sec)

      新建表

      mysql> create table user01(

      -> id varchar(20) NOT NULL,

      -> userName varchar(10) NOT NULL,

      -> age int(11) default'0',

      -> sex char(2) NOT NULL default'm',

      -> PRIMARY KEY (id)

      -> )TYPE=InnoDB;

      Query OK, 0 rows affected, 1 warning (0.02 sec)mysql>desc student;

      插入和删除表中的数据

      Create table student(stuName varchar(20),age varchar(20),id varchar(20),set0 char(1));

      插入

      mysql> insert into student(id,stuName) values('1','tomcat');

      Query OK, 1 row affected (0.00 sec)

      删除

      mysql> delete from student where id='1';

      Query OK, 1 row affected (0.01 sec)

      删除表中所有数据

      mysql> truncate table student;

      Query OK, 1 row affected (0.01 sec)

      删除表

      mysql> create table temp(t varchar(1));

      Query OK, 0 rows affected (0.00 sec)

      mysql> drop table temp;

      Query OK, 0 rows affected (0.00 sec)

      创建新用户并给予权限

      mysql> grant all privileges on *.* to dbuser@localhost identified by '1234'

      with grant option;

      更改Mysql用户密码

      c:Mysql5.0in>mysqladmin -u root -p password 1234

      Enter password: ****

      备份数据库及表

      我们用mysqldump命令来备份数据库

      c:mysqlin>mysqldump –u root –p 3306 mysql>d:ackup.sql

      执行此语句将把mydb 备份到D盘的backup.sql文件中

      备份多个数据库表

      c:mysqlin>mysqldump –u root –p 3306 school user01 user >d:ackup.sql

      此句的意思是把school库中的user01表和user表的内容和表的定义备份到D盘backup.sql文件中。

      备份所有的数据库

      c:myqlin>mysqldump –u root –p 3306 –all –database>d:backup.sql

      还原Mysql数据库

      c:mysqlinmysql –u root –p 3306 school

      还原其中的一个表

      mysql> source d:ooks.sql;

      ERROR:

      Unknown command ''.

      Query OK, 0 rows affected (0.00 sec)

      Query OK, 1 row affected (0.00 sec)

      退出Mysql连接

      mysql>quit(exit)

      关闭mysql服务

      C:mysqlin>net mysql

  • 相关阅读:
    HTML的基本骨架
    2017.7.27
    2017.7.26
    2017.7.25
    2017.7.24
    2017.7.22
    2017.7.21
    Javascript Step by Step
    Javascript Step by Step
    Javascript Step by Step
  • 原文地址:https://www.cnblogs.com/wanghuaijun/p/5527760.html
Copyright © 2011-2022 走看看