MySQL必知必會---基礎環境

來源:互聯網
上載者:User

標籤:mysql

基礎環境

1.OS版本centos7
2.mariadb-5.5.56

[[email protected] ~]# yum install -y mariadb

已載入外掛程式:fastestmirror
base | 3.6 kB 00:00:00
elasticsearch-2.x | 2.9 kB 00:00:04
epel/x86_64/metalink | 4.8 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
logstash-2.1 | 951 B 00:00:00
updates | 3.4 kB 00:00:00
(1/6): base/7/x86_64/group_gz | 166 kB 00:00:00
(2/6): extras/7/x86_64/primary_db | 143 kB 00:00:00
(3/6): epel/x86_64/group_gz | 88 kB 00:00:00
(4/6): updates/7/x86_64/primary_db | 1.2 MB 00:00:00
(5/6): epel/x86_64/updateinfo | 926 kB 00:00:13
(6/6): epel/x86_64/primary_db | 6.4 MB 00:00:44
Determining fastest mirrors

  • base: mirrors.huaweicloud.com
  • epel: mirrors.sohu.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    軟體包 1:mariadb-5.5.56-2.el7.x86_64 已安裝並且是最新版本
    無須任何處理
    [[email protected] ~]#

以上使用yum安裝mariadb資料庫

systemctl start mariadb

啟動資料庫

systemctl status mariadb

查看資料庫狀態

如啟動失敗:請查看相關log

預設情況下使用mysql命令直接進入命令列

SHOW DATABASES;
查看資料庫
use test;

建立一個使用者表

CREATE TABLE user (
id int(10) unsigned NOT NULL auto_increment,
sex tinyint(1) default 1 COMMENT ‘性別:0女;1男;2保密‘,
age int(3) default 1 COMMENT ‘年齡‘,
province char(254) default NULL COMMENT ‘所在省份‘,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

向表中插入測試資料

INSERT INTO user(sex,age,province) VALUES
(‘1‘,‘22‘,‘北京‘),
(‘0‘,‘25‘,‘廣東‘),
(‘0‘,‘56‘,‘天津‘),
(‘1‘,‘14‘,‘北京‘),
(‘0‘,‘36‘,‘廣東‘),
(‘1‘,‘68‘,‘湖南‘),
(‘1‘,‘45‘,‘北京‘),
(‘1‘,‘17‘,‘河北‘),
(‘2‘,‘33‘,‘天津‘),
(‘1‘,‘27‘,‘湖南‘),
(‘1‘,‘29‘,‘北京‘),
(‘2‘,‘70‘,‘廣東‘),
(‘0‘,‘24‘,‘北京‘)

以上為測試用表。

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.