YUM安装MySQL5.7

关系型数据库:MySQL、MaraiDB、Oracle、SQL Server、PostgreSQL、DB2
MySQL引擎包括:ISAM、MyISAM、InnoDB、Memory、CSV、BlackHole、Archive、Performance_Schema、Berkeley、Federated、Cluster/NDB
YUM安装MySQL5.7
Mysql服务器安装YUM/rpm mysql5.7.16-10
yum install mysql-server mysql-devel mysql-libs -y CentOS 6.X版本
YUM安装MySQL5.7
yum install mariadb-server mariadb mariadb-libs -y CentOS 7.X版本
Centos7安装Mysql5.7
1-由于CentOS 的yum源中没有mysql,需到mysql的官网下载yum repo配置文件
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
YUM安装MySQL5.7
2-进行repo的安装
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo mysql-community-source.repo执行完成后会在/etc/yum.repos.d/目录下生成两个repo文件mysql-community.repo mysql-community-source.repo
YUM安装MySQL5.7
YUM安装MySQL5.7
YUM安装MySQL5.7

3-yum命令即可完成安装
yum install mysql-server
YUM安装MySQL5.7
4-启动Mysql
systemctl start mysqld
YUM安装MySQL5.7
5-获取安装时的临时密码: 3>2X-WNr6aal
grep ‘temporary password‘ /var/log/mysqld.log
倘若没有:(1)删除原来安装过的mysql残留的数据
rm -rf /var/lib/mysql
2)再启动mysql
YUM安装MySQL5.7
6-登录
mysql -u root -p
YUM安装MySQL5.7
7-修改密码
set password=password("yourpassword")
YUM安装MySQL5.7
8-数据库常用命令
查看数据库
show databases;
YUM安装MySQL5.7
创建数据库
create database jfedu;
YUM安装MySQL5.7
进入数据库
use jfedu;
显示数据库表
show tables;
YUM安装MySQL5.7
创建名为t1表,并创建两个字
create table t1 (id varchar(20),name varchar(20));
YUM安装MySQL5.7
向表中插入数据
insert into t1 values("1","jfedu");
YUM安装MySQL5.7
查看t1表数据内容
select from t1;
YUM安装MySQL5.7
id,age多条件查询
select
from t1 where id=1 and age=‘jfedu‘;
查看t1表数据内容
desc t1
YUM安装MySQL5.7
修改name字段长度
alter table t1 modify column name varchar(20);
update t1 set name=‘jfedu.net‘ where id=1;
刷新权限
flush privileges;
YUM安装MySQL5.7
清空表内容
delete table t1;
YUM安装MySQL5.7
清空表
drop table t1;
YUM安装MySQL5.7
删除test数据库
drop database test;
YUM安装MySQL5.7
查看数据库字符集
show variables like ‘%char%‘;
YUM安装MySQL5.7
查看MYSQL存储引擎
show engines;
YUM安装MySQL5.7
查看数据库的默认引擎
show variables like ‘%storage_engine%‘;
YUM安装MySQL5.7

相关推荐