Redhat7 安装mariadb(原mysql)

Redhat7 安装mariadb(原mysql)


安装:

# yuminstall mariadb mariadb-server

 

启动并开机启动:

#systemctl start mariadb

#systemctl enable mariadb

 

此时mysqlroot密码为空

# mysql �Curoot

  • user mysql;

  • update user set password=password(‘123456’) where user=root;

  • flush privileges;

  • quit

 

开防火墙:

#firewall-cmd �Cpermanent �Cadd-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;

 


你可能感兴趣的:(mariaDB)