標籤:
sudo apt-get update //用於更新源,擷取軟體包列表sudo apt-get upgrade //用於升級指定軟體包install //安裝remove //移除軟體包autoremove //自動移除全部不實用的軟體包purge //軟體包與設定檔一起移除source //用於下載指定包的源碼check //用於檢驗依賴是否有損壞
Linux 安裝MySql:
1. sudo apt-get install mysql-server
然後出現提示介面:
a.設定mysql使用者密碼
b.確認密碼
2.確認mysql資料庫是否啟動
ps -ef|grep mysqld
3.訪問mysql資料庫
mysql -u root -p
輸入密碼後進入資料庫;
顯示當前mysql下所有資料庫:show databases;
進入某個資料庫:use xxx;
顯示當前資料庫下所有的表:show tables;
退出當前資料庫:quit
4.卸載mysql
sudo apt-get autoremove --purge mysql-server
5.推薦軟體:xampp ,包含Apache、MySQL、PHP
添加執行許可權: sudo chmod 777 xampp-lnux-x64-5.5-installer.run
安裝xampp: sudo ./xampp-lnux-x64-5.5-installer.run
一路點擊next進行安裝
安裝好後,點擊Manage Servers,點擊start,開啟Mysql與Apache
開啟瀏覽器,輸入localhost,然後點擊中文,點擊左側phpMyAdmin,即可看見控制台
=====================================================
使用MySQL資料庫和表
1.建立使用及刪除MySQL資料庫
XAMPP -> bin ,可使用MySQL終端工具,從這裡啟動終端:
- 進入MySQL: ./mysql -u root -p
- 建立資料庫abel:create database abel;
(注意:資料庫名字不能重名、不能太長、不能為純數字、不能使用關鍵字如select等,另外資料庫名字起名要謹慎,不要隨意修改)
- 切換/進入abel資料庫: use abel;
- 刪除abel資料庫:drop database abel;
2.MySQL資料庫的表操作
- 建立資料表: create table tbl_user(id int(3),name varchar(8),password varchar(20));
- 修改資料表名字:
alter table tbl_user rename to tbl_member;
或者
rename table tbl_user to tbl_member;
- 為資料表添加一個欄位email: alter table tbl_user add eamil varchar(255) not null;
- 修改資料表已有欄位id為newid: alter table tbl_user change id newid int(3);
- 刪除資料表已有欄位eamil: alter table tbl_user drop email;
- 刪除資料表:drop table tbl_user;
3.獲得資料庫和表的資訊以及資料庫物理檔案簡介
- 訪問MySQL資料庫:mysql -u root -p
- 顯示當前MySQL下所有資料庫:show databases;
- 進入某個資料庫:use xxx;
- 顯示當前資料庫下所有的資料表:show tables;
- 顯示xxx資料庫下的所有資料表:show tables from xxx;
- 查看資料表tbl_user的結構:describe tbl_user;
Linux下MySQL安裝與操作