标签:mariadb
Redhat7 安装mariadb(原mysql)
安装:
# yuminstall mariadb mariadb-server
启动并开机启动:
#systemctl start mariadb
#systemctl enable mariadb
此时mysql的root密码为空
# mysql –uroot
user mysql;
update user set password=password(‘123456’) where user=root;
flush privileges;
quit
开防火墙:
#firewall-cmd –permanent –add-service=mysql
#firewall-cmd --reload
# vi/etc/my.cnf (mysqld下)
Skip-networking= 1 (关闭远程通过ip进行连接,默认是允许的)
:wq
link 模糊查询
link ‘%a%’ 中间含字母a的
link ‘_a%’ 以a结尾的
link ‘%a_’ 以a开头的
语句示例(注意区分函数、字段、表名):
select *from worker where sal >= 2500;
select *from worker where sal != 2500;
select*from worker where deptno in(2,4);
select *from worker where sal between 1500 and 2500;
selectavg(sal) from worker;
selectmax(sal) from worker;
selectmin(sal) from worker;
select *from worker order by deptno; (升序排列)
select *from worker order by deptno desc; (降序排列)
selectdeptno,max(sal) from worker group by deptno;
createtable test as select * from worker;
内连接:
selectstudent,sno,student.sname,coll.cname from student join coll onstudent.cno=coll.con;
左外连接:
select s.sno,s.sname,c.cnamefrom student as s left join coll as c on s.cno=c.cno;
右连接:
select s.sno,s.sname,c.cnamefrom coll as c right join student as s on s.cno=c.cno;
本文出自 “linux” 博客,请务必保留此出处http://yangzhiming.blog.51cto.com/4849999/1721717
标签:mariadb
原文地址:http://yangzhiming.blog.51cto.com/4849999/1721717