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.7mysql

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.7sql

相關文章
相關標籤/搜索