標籤:test .sql 介紹 names 設定 應該 varchar set des
摘要
在本篇博文中。筆者將從基礎出發。介紹Mysql在Linux環境下的安裝和基本使用命令,僅適用於Mysql剛開始學習的人。大牛請繞道……
安裝Mysql資料庫
這裡介紹最最簡單的安裝方式,至於編譯安裝,能夠下載安裝包, ./configure 產生Makefile。然後 make clean, make , make test, make install 我想這些命令應該非常基本了吧,這裡不再敖述。
1. 安裝命令
[email protected]:~$ sudo apt-get install mysql-server mysql-client
2. 查看資料庫版本號碼,這裡password為“11”
[email protected]:~$ sudo mysqladmin -u root -p versionEnter password: mysqladmin Ver 8.42 Distrib 5.1.70, for debian-linux-gnu on i486Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3. 查看Mysql服務狀態。啟動或者關閉Mysql服務
[email protected]:~$ service mysql statusmysql start/running, process 899[email protected]:~$ sudo /etc/init.d/mysql start|stop|restart
4. 登陸資料庫。並退出操作
命令裡的 -u 指的是username, 這裡指的是 root, -p 後接password, 這裡指安裝資料庫時候設定的password,筆者的為11
[email protected]:~$ sudo mysql -uroot -p11
5. 資料庫內的基本操作
// 顯示資料庫mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || jxc || mysql |+--------------------+3 rows in set (0.08 sec)// 使用某個資料庫mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed// 建立資料庫mysql> create database thinkphp;Query OK, 1 row affected (0.00 sec)// 刪除資料庫mysql> drop database thinkphp;Query OK, 0 rows affected (0.07 sec)// 顯示資料庫中的某張表mysql> show tables;// 顯示某個表的結構mysql> describe slow_log;// 選擇顯示的表內容mysql> select * from slow_log;Empty set (0.00 sec)// 刪除表mysql> drop table slow_log;// 匯入資料庫mysql> source /var/www/webPage.sql;或者命令: ~$ sudo mysql –uroot –p11 thinktest < WebPage.sql
mysql 表結構CRUD操作
加入表欄位 alter table tablename add elemName varchar(10) not null;改動某個表欄位類型 alter table tablename change elemName elemNewName varchar(10) null; alter table tablename modify elemName varchar(10) null;刪除某個欄位 alter table tablename drop elemName;向資料表中插入資料 insert into tablename (elem1,elem2,...) values (A,B,...);刪除資料表中資料 delete from tablename where id>1 order by time limit 1;更新資料表中資料 UPDATE tablename SET elem1=1, elem2=2 WHERE id=1;
??
Ubuntu系統下的Mysql安裝與使用