MySQL(一)

來源:互聯網
上載者:User

標籤:res   修改   current   span   int   creat   改密碼   type   register   

 

mysql命令

 

一、初試命令:

show databases; # 查看當前Mysql都有那些資料,根目錄都有那些檔案夾

create database 資料庫名; # 建立檔案夾

use 資料庫名; # 使用選中資料庫,進入目錄

show tables; # 查看當前資料庫下都有那些表,

create table 表名(nid int,name varchar(20), pwd varchar(64)); # 建立資料庫表

select * from 表名; # 查看錶中的所有資料

insert into 表名(nid,name,pwd) values(1,‘alex‘,‘123‘); # 插入資料

select * from 表名;

 

樣本:

 1 [[email protected] ~]# mysql -uroot -p  #再輸入密碼 2 Welcome to the MySQL monitor.  Commands end with ; or \g. 3 Your MySQL connection id is 4 4 Server version: 5.5.49 MySQL Community Server (GPL) 5  6 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. 7  8 Oracle is a registered trademark of Oracle Corporation and/or its 9 affiliates. Other names may be trademarks of their respective10 owners.11 12 Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.13 14 15 #建立資料庫16 mysql> create database test1;17 Query OK, 1 row affected (0.02 sec)18 19 20 #進入test1庫中21 mysql> use test1;22 Database changed23 24 #建立表tb1(nid和name欄位)25 mysql> create table tb1(nid int,name varchar(20));26 Query OK, 0 rows affected (0.06 sec)27 28 #建立tb2 (nid和name欄位)29 mysql> create table tb2(nid int,name varchar(20));30 Query OK, 0 rows affected (0.01 sec)31 32 #查看錶33 mysql> show tables;34 +-----------------+35 | Tables_in_test1 |36 +-----------------+37 | tb1             |38 | tb2             |39 +-----------------+40 2 rows in set (0.01 sec)41 42 #查看所有表43 mysql> select * from tb1;44 Empty set (0.01 sec)45 46 #往表中插入資料47 mysql> insert into tb1(nid,name)values(1,‘alex‘);48 Query OK, 1 row affected (0.01 sec)49 50 #往表中插入資料51 mysql> insert into tb1(nid,name)values(1,‘eric‘);52 Query OK, 1 row affected (0.01 sec)53 54 #查看所有表55 mysql> select * from tb1;56 +------+------+57 | nid  | name |58 +------+------+59 |    1 | alex |60 |    1 | eric |61 +------+------+62 2 rows in set (0.00 sec)63 64 #退出65 mysql> exit66 Bye

 

二、使用者授權


使用者管理特殊命令:

建立使用者
create user ‘使用者名稱‘@‘IP地址‘ identified by ‘密碼‘;


刪除使用者
drop user ‘使用者名稱‘@‘IP地址‘;


修改使用者
rename user ‘使用者名稱‘@‘IP地址‘; to ‘新使用者名稱‘@‘IP地址‘;;


修改密碼
set password for ‘使用者名稱‘@‘IP地址‘ = Password(‘新密碼‘)

 

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.