mysql資料庫入門

來源:互聯網
上載者:User

標籤:

在很多地方都有人提到MySQL這個資料,之前沒有接觸過的mysql資料庫的童鞋們可以跟我一起走進mysql的世界。

 http://hovertree.com/menu/mysql/

安裝我就不多說了,都是傻瓜的安裝。

 

安裝好了之後就可以看到服務裡多了個服務。

 

 

當然要啟動它。 根據自己的需要設定成自動還是手動了。

看到這個服務的路徑 "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --defaults-file="C:\Program Files\MySQL\MySQL Server 5.5\my.ini" MySQL

 

找到這個檔案夾裡看到一些mysql的 命令。可以點擊mysql這個命令來啟動 當然也可以在運行裡輸入cmd 然後 mysql -uroot - p 來啟動

 

我這個不知道安裝後環境變數沒有 所以在CMD裡直接敲這個是沒有效果的。必須先配置path 也就是環境變數加個這個mysql的命令路徑C:\Program Files\MySQL\MySQL Server 5.5\bin     詳細操作如下

右擊“我的電腦”,選擇“屬性”,再選擇“進階”,接著點擊“環境變數”,在“系統變數”一欄裡雙擊“Path”, 在“變數值”最後面添加“;”和C:\Program Files\MySQL\MySQL Server 5.5\bin    

或者在運行裡直接操作如下

運行 cmd  輸入 D:\>set path=%path%;C:\Program Files\MySQL\MySQL Server 5.5\bin

如下

 

  

至於環境變數配置已經說的差不多了。實在不知道就留言或者查資料。。。。

 http://hovertree.com/h/bjaf/008kix5q.htm

 

關於mysql的一些簡單操作如下

 

mysql -uroot -p    登入mysql

啟動服務
net start wampmysqld    
關閉服務

net stop wampmysqld

或者這樣登入mysql
mysql --urser root --password

退出mysql
quit
exit

 

登入mysql
D:\>mysql --host localhost --user root --password


簡寫
D:\>mysql -hlocalhost -uroot -p


本機登入
D:\>mysql -uroot -p


2。建立MYSQL帳號和表

 

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

或者直接輸入完命令後輸入\G 如下
mysql> show databases \g
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)


後面跟\C不執行命令
mysql> desc test \c

 


mysql 建立使用者

mysql> grant all on test.* to "mrzhou"@"localhost" identified by "mrzhou"
    -> ;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye

D:\>mysql --user mrzhou --password
Enter password: ******

或者這樣登入
D:\>mysql -umrzhou -p
Enter password: ******

建立資料庫
mysql> create datatable mrzhou;

建立表
mysql> create table student(id int(10) primary key auto_increment,name varch
0),age tinyint(2));
Query OK, 0 rows affected (0.13 sec)


mysql> desc student;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(10)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(30) | YES  |     | NULL    |                |
| age   | tinyint(2)  | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)

 

向表中插入資料

mysql> insert into student(name,age)values("張三",33);
Query OK, 1 row affected (0.05 sec)

mysql> select * from student;
+----+------+------+
| id | name | age  |
+----+------+------+
|  1 | 張三 |   33 |
+----+------+------+
1 row in set (0.00 sec)

 

匯出庫
D:\>mysqldump -uroot -p mrzhou>d:mrzhou.sql
Enter password:


刪除表
mysql> drop table student;
Query OK, 0 rows affected (0.03 sec)

匯入庫
D:\>mysql -uroot -p mrzhou < d:/mrzhou.sql
Enter password:

或者用

mysql> source d:/mrzhou.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

轉自:http://hovertree.com/h/bjaf/mysqlrumen.htm

推薦:http://www.cnblogs.com/roucheng/p/mysqlfenqu.html

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.