mysql查看資料庫命令

來源:互聯網
上載者:User

標籤:

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.02sec)mysql>desc student;

  插入和刪除表中的資料

  Create table student(stuName varchar(20),age varchar(20),idvarchar(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[email protected] identified by ‘1234‘

  with grant option;

  更改Mysql使用者密碼

  c:\Mysql5.0\bin>mysqladmin -u root -p password1234

  Enter password: ****

  備份資料庫及表

  我們用mysqldump命令來備份資料庫

  c:\mysql\bin\>mysqldump –u root –p 3306mysql>d:\backup.sql

  執行此語句將把mydb 備份到D盤的backup.sql檔案中

  備份多個資料庫表

  c:\mysql\bin\>mysqldump –u root –p 3306 schooluser01 user >d:\backup.sql

  此句的意思是把school庫中的user01表和user表的內容和表的定義備份到D盤backup.sql檔案中。

  備份所有的資料庫

  c:\myql\bin>mysqldump –u root –p 3306 –all–database>d:backup.sql

  還原Mysql資料庫

  c:\mysql\bin\mysql –u root –p 3306 school

  還原其中的一個表

  mysql> source d:\books.sql;

  ERROR:

  Unknown command ‘\b‘.

  Query OK, 0 rows affected (0.00 sec)

  Query OK, 1 row affected (0.00 sec)

  退出Mysql串連

  mysql>quit(exit)

  關閉mysql服務

  C:\mysql\bin>net mysql

mysql查看資料庫命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.