標籤:mysql basic
安裝mysql
[[email protected] ~]# yum install mysql mysql-server mysql-devel
2.啟動mysql,並設定開機自啟動
[[email protected] ~]# service mysqld start/stop/restart/status #啟動/關閉/重啟/狀態chkconfig mysqld on/off[[email protected] ~]# chkconfig --list | grep mysqldmysqld 0:off1:off2:on3:on4:on5:on6:off
3.相關配置
/etc/my.cnfmysql設定檔/var/lib/mysqlmysql資料庫檔案port:3306mysql預設連接埠
5.注意事項
mysql> quit #quit,退出,等同於ctrl+cBye[[email protected] ~]# ; #MySQL 絕大對數語句都是以分號結尾,注意是英文模式下的分號。字元和字串用 ‘ ‘ 引起;
4.mysql初始化及登入
[[email protected] ~]# mysql -u root -p ‘123456‘[[email protected] ~]# mysql -u root -p -h localhost “-h” 指定伺服器位址
5.建立、查看及刪除當前資料庫
mysql> CREATE DATABASE ultraera;Query OK, 1 row affected (0.00 sec)mysql> SHOW DATABASES;+--------------------+| Database |+--------------------+| information_schema || mysql || test || ultraera |+--------------------+4 rows in set (0.00 sec)mysql> DROP DATABASE ultraera;Query OK, 0 rows affected (0.00 sec)
6.建立、查看及刪除當前表格
#建立表格之前要先選擇資料庫mysql> use ultraera;Database changedmysql> CREATE TABLE ultraera( #create 建立表格,至少1列 -> id int NOT NULL, #NOT NULL 不為空白,int 整型 -> name char(20) NOT NULL, #char() 字元型 ,()內定義字元長度 -> age int NOT NULL, -> );Query OK, 0 rows affected (0.01 sec)mysql> DESC ultraera;+-------+----------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------+----------+------+-----+---------+----------------+| id | int(11) | NO | | NULL | || name | char(20) | NO | | NULL | || age | int(11) | NO | | NULL | |+-------+----------+------+-----+---------+----------------+3 rows in set (0.00 sec)mysql> DROP TABLE ultraera ;Query OK, 0 rows affected (0.00 sec)
本文出自 “南非部落” 部落格,請務必保留此出處http://ultraera.blog.51cto.com/6640392/1583524
MySQL資料庫基礎