Mariadb配置:
yum groupinstall mariadb mariadb-client
yum grouplist |grep maria
systemctl enable mariadb.service
systemctl restart mariadb.service
firewall-cmd --permanent --add-service=mysql
firewall-cmd --reload
firewall-cmd --permanent --list-all
mysql_secure_installation, 輸入root密碼,初始爲空。
set root password->Remove anon user?yes->Disallow root login?yes->Remove test database?yes->Reload?yes
mysql -uroot -ptianyun; 創建數據庫
show databases;
create database concats; show databases;
導入數據庫:
mysql -uroot -ptianyun concats < /home/student/mariadb.dump
或者:
use concats; select database();
source /home/student/mariadb.dump;
show tables; 可以看到一張相應的表
授權用戶訪問, 可能要指定網段
help grant; 查看授權命令
grant select (limitation list) on concats.* to 'luigi@'%
flush privileges 刷新權限列表(系統關鍵字不分大小寫,表名和庫名分大小寫)
mysql -uluigi -h 172.25.0.11 -ptianyun
use concats; select * from product;
單表查詢:
desc product \G 或 desc product; 查看錶結構
select * from product where id_category='2'
select count(*) from product where id...
select * from product where ... and ... 下劃線_表示匹配一個字符,%表示多個
select * from product where name regexp '^T'; 正則表達式