1.mysql 的守護程序是mysqld
a.開啟mysql資料庫命令
[root@instance-sk9hvjmd ~]# service mysqld start
redirecting to /bin/systemctl start mysqld.service
b.關閉mysql資料庫命令
[root@instance-sk9hvjmd ~]# service mysqld stop
redirecting to /bin/systemctl stop mysqld.service
c.重啟mysql資料庫命令
[root@instance-sk9hvjmd ~]# service mysqld restart
redirecting to /bin/systemctl restart mysqld.service
d.檢查mysql伺服器是否在執行
[root@instance-sk9hvjmd ~]# ps -el|grep mysqld
1 s 27 2923 1 0 80 0 - 284356 poll_s ? 00:03:55 mysqld
2.查詢已安裝的myslq 版本:
[root@instance-sk9hvjmd ~]# rpm -qa|grep mysql
mysql-community-server-5.7.16-1.el7.x86_64
mysql-community-common-5.7.16-1.el7.x86_64
mysql-community-client-5.7.16-1.el7.x86_64
mysql-community-libs-5.7.16-1.el7.x86_64
3.檢視檔案安裝路徑
[root@instance-sk9hvjmd ~]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
4.查詢執行檔案所在路徑(資料夾位址)
[root@instance-sk9hvjmd ~]# which mysql
/usr/bin/mysql
5.mysql登陸
mysql -u username -p
[root@instance-sk9hvjmd ~]# mysql -u root -p
enter password:
6.查詢資料庫
show databases;
mysql> show databases;
| database |
| information_schema |
| devtest |
| mblog |
| mysql |
| performance_schema |
| sys |
| test |
7 rows in set (0.08 sec)
7.建立資料庫
create database [dbname];
mysql> create database runoob;
query ok, 1 row affected (0.10 sec)
8.刪除資料庫
drop database [dbname];
mysql> drop database runoob;
query ok, 0 rows affected (0.17 sec)
9.選擇資料庫
use [dbname];
mysql> use devtest
database changed
10.查詢資料表
mysql> show tables;
| tables_in_devtest |
| insurance_data |
| test |
| insurance |
| student |
4 rows in set (0.00 sec)
11.建立資料表
mysql> create table if not exists `runoob_tbl`(
-> `runoob_id` int unsigned auto_increment,
-> `runoob_title` varchar(100) not null,
-> `runoob_author` varchar(40) not null,
-> `submission_date` date,
-> primary key ( `runoob_id` )
-> )engine=innodb default charset=utf8;
query ok, 0 rows affected (0.18 sec)
12.清楚資料表資料
mysql> delete from runoob_tbl;
query ok, 1 row affected (0.02 sec)
13.刪除資料表
mysql> drop table runoob_tbl;
query ok, 0 rows affected (0.04 sec)
14.查指定資料庫占用空間大小
mysql> select table_name, concat(truncate(data_length/1024/1024,2),' mb') as data_size,
-> concat(truncate(index_length/1024/1024,2),' mb') as index_size
-> from information_schema.tables where table_schema = 'devtest'
-> group by table_name
-> order by data_length desc;
| table_name | data_size | index_size |
| student | 163.67 mb | 0.00 mb |
| insurance | 0.07 mb | 0.00 mb |
| insurance_data | 0.07 mb | 0.00 mb |
| test | 0.01 mb | 0.00 mb |
4 rows in set (0.02 sec)
15.查所有資料庫占用空間大小
mysql> select table_schema, concat(truncate(sum(data_length)/1024/1024,2),' mb') as data_size,
-> concat(truncate(sum(index_length)/1024/1024,2),'mb') as index_size
-> from information_schema.tables
-> group by table_schema
-> order by data_length desc;
| table_schema | data_size | index_size |
| devtest | 163.84 mb | 0.00mb |
| test | 461.15 mb | 60.39mb |
| mblog | 0.25 mb | 0.07mb |
| information_schema | 0.15 mb | 0.00mb |
| performance_schema | 0.00 mb | 0.00mb |
| mysql | 4.86 mb | 0.21mb |
| sys | 0.01 mb | 0.00mb |
7 rows in set (1.14 sec)
c mysql命令 最基本的mysql命令
在windows95 98 me上啟動mysql服務 c mysql bin mysql 在windwosnt 2000 xp上啟動 安裝myslq服務 c mysql bin mysql instal 啟動mysql服務 c mysql bin net start mysql 連線mysql my...
c mysql命令列 mysql 命令列工具
1 mysql命令選項 2 mysql命令 3 mysql日誌 4 mysql服務端幫助 5 執行mysql指令碼 6 使用技巧 mysql是乙個能夠編輯輸入行的簡單sql shell,支援互動式和非互動式訪問。使用互動式時,查詢結果以ascii表的格式展示。使用非互動式時,查詢結果以製表符分隔的格...
Linux下c mysql程式的編譯命令
最好用 gcc o test test.c mysql config cflags libs 其它的編譯命令 gcc o test test.c i usr include mysql l usr lib mysql lmysqlclient lz lm gcc o test test.c i us...