千家信息网

mariadb数据库

发表于:2025-11-14 作者:千家信息网编辑
千家信息网最后更新 2025年11月14日,##配置网络vim/etc/sysconfig/network-scripts/ifcfg-eth0 写网络配置文件systemctl restart network 重启网络##配置yum源vim
千家信息网最后更新 2025年11月14日mariadb数据库

##配置网络
vim/etc/sysconfig/network-scripts/ifcfg-eth0 写网络配置文件
systemctl restart network 重启网络
##配置yum源
vim /etc/yum.repos.d/rhel_dvd.repo 写yum源配置文件
yum clean all 重置yum源
##修改服务器名字
hostnamectl set-hostnamemariadb.westos.com 更改本地服务器名字
hostname 查看本地本地服务器名字


####### mariadb数据库########### 数据库厂商 mysql oracle

一 数据库的安装与配置
1 yum install mariadb-server -y ##安装mariadb

2 systemctl start mariadb ##开启mariadb服务
3 mysql ###进入mysql数据库
4 netstat -antlpe | grep mysql ###查询mysqul
5 vim /etc/my.cnf ###mysqul的配置文件
skip-networking=1

6 systemctl restart mariadb ###重启mariadb服务
7 netstat -antlpe | grep mysqul
8 mysql
9 mysql_secure_installation ###mysql安全内容配置
(1)Enter current password for root(enter for none):[Enter]
(2)Set root password? [Y/n]Y
New password: ###输入新密码
Re-enter new password: ###确认密码
(3)Remove anonymous users? [Y/n]Y
(4)Disallow root login remotely?[Y/n] Y
(5)Remove test database and accessto it? [Y/n] Y
(6)Reload privilege tables now?[Y/n] Y
10 mysql -uroot -p
11 mysql
图:


二 数据库基本语句
1 登陆
(1)mysql -uroot -pqwer1234 ##qwer1234是密码
(2)mysql -uroot -p
Enter password: ##密码不显示;安全性能高
2 查询
(1)show databases; ###显示数据库

(2)use mysql ###进入mysql库

(3)show tables; ###显示当前库中表的名字
(4)select * from user ###查询user表中的所有内容(* 可以用表中所有字段来代替)
(5)desc user; ###查询表的结构 (显示所有字段的名称)


3 数据库及表的建立
(1)create database westos; ####创建westos库
show databases; ###显示数据库

(2)use westos ###进入westos库
create table linux( ####linux表
-> username varchar(15) not null,
-> password varchar(15) not null); ###表中含有username,password两个字段;字符长度最大为15个,都不为空。(字符长度可根据需要更改)

desc linux; ###查询表的结构 (显示所有字段的名称)

(3)insert into linux values ('user','123'); ###向表中插入数据,
select * from linux; ###查询linux表中的所有内容
insert into linux values('user1',password('123') );
###向表中插入数据,加密密码


4 更新数据库信息
(1)update linux set password=('234') where username='user1';
##### 更新user1的密码
select * from linux; ###查询linux表中的所有内容

(2)update linux set password=password('123') where username='user';
#####更新use的密码,并加密
select * from linux;

(3)alter table linux add age varchar(4);
####增加age字段到表的最后一列
select * from linux;

(4)alter table linux add exam varchar(4) after password;
####增加exam字段到指定位置
select * from linux;

(5)alter table linux drop exam; ####删除linux中的exam字段
select * from linux;

(6)update linux set password=password('123')where ( username='user' or username='user1');
####更新两个用户的密码,并加密
select * from linux;


5 数据库的备份
2 mysqldump -u root -pqwer1234 --all-database
####备份所有表中的所有数据
3 mysqldump -u root -pqwer1234 --all-database --no-data
####备份所有表,但不备份数据
4 mysqldump -u root -pqwer1234 westos
####备份westos库
5 mysqldump -u root -pqwer1234 westos > /mnt/westos.sql
####备份westos库并把数据保存到/mnt/westos.sql
8 mysql -uroot -pqwer1234 -e "create database westos;"
####建立westos库
9 mysql -u root -pqwer1234 westos < /mnt/westos.sql
####把数据导入westos库
10 mysql -u root -pqwer1234
16 mysqldump -u root -pqwer1234 westos linux > /mnt/linux.sql
####备份westos库中的linux表并把数据保存到/mnt/linux.sql
17 mysqldump -u root -pqwer1234 westos test> /mnt/test.sql
####备份westos库中的test表并把数据保存到/mnt/test.sql
27 mysql -u root -pqwer1234 -e "show tables from westos"
###显示westos库中表的名字
28 mysql -u root -pqwer1234 westos < /mnt/test.sql
####把test表中数据导入westos库
29 mysql -u root -pqwer1234 -e "show tables from westos"
###显示westos库中表的名字



6 数据库的删除
(1) 删除表中数据 delete from linux where username='username';
mysql -u root -pqwer1234
MariaDB [(none)]> usewestos ###进入westos库
MariaDB [westos]> select * fromlinux; ###查询linux表中的所有内容
delete from linux whereusername='user1'; ###删除linux表中的user1的数据
delete from linux whereusername='user'; ###删除linux表中的user的数据
select * from linux; ###查询linux表中的所有内容

(2)删除表
drop table linux;
(3)删除库
drop database westos;



7 用户授权
(1)建立用户
MariaDB [(none)]> create userlee@localhost identified by ' lee';
####建立用户lee本机登陆
MariaDB [(none)]> create userlee@'%' identified by ' lee';
####建立lee用户,网络登陆


(2)用户授权
MariaDB [(none)]> grantinsert,update,delete,select on westos.test to lee@localhost;
### 本机登陆lee,授权
MariaDB [(none)]> grant selecton westos.* to lee@'%' ;
####网络登陆lee,授权

(3)查看用户权力
MariaDB [(none)]> show grantsfor lee@'%'
####查看用户权力
MariaDB[(none)] > show grantsfor lee@localhost;、
####查看用户权力

(4)去除用户授权权力
MariaDB [(none)]> revoke deleteon westos.test from lee@localhost;
######去除用户授权权力
MariaDB [(none)]> show grantsfor lee@localhost; 查看权限

(5)删除用户
MariaDB [(none)]> selectUser,Host from mysql.user;查看用户
MariaDB [(none)]]> drop userlee@'%'; 删除用户
MariaDB [(none)]> selectUser,Host from mysql.user;查看用户


8 密码修改
(1)超级用户密码知道
mysqladmin -uroot -p234 password lee ##修改超级用户密码为lee
(2)超级用户密码忘记
[root@mariadb mnt]# mysqld_safe--skip-grant-tables &
####开启mysql登陆接口并忽略授权表
[root@mariadb mnt]# mysql ###进入mysql
MariaDB [(none)]> selectUser,Host,Password from mysql.user;
####查看mysql.user中用户及用户密码
MariaDB [(none)]> updatemysql.user set Password=password('234') where User='root'; ##更新超级用户密码信息为234
MariaDB [(none)]> select User,Host,Passwordfrom mysql.user;
####查看mysql.user中用户及用户密码
MariaDB [(none)]> quit
[root@mariadb mnt]# fg
[root@mariadb mnt]# killall -9 mysqld_safe ####关闭mysqld_safe进程
[root@mariadb mnt]# ps aux | grep mysql ###过滤mysql的所有进程
[root@mariadb mnt]# kill -9 mysqlpid ####关闭mysql的所有进程
[root@mariadb mnt]# systemctl restart mariadb ###重启mariadb服务
[root@mariadb mnt]# mysql -uroot -p234 ###登陆测试



三 数据库的页管理工具
1.安装
156 yum install httpd php php-mysql -y ##安装 httpd php php-mysql三个安装包
yum install php-mysql.x86_64-y
yum install httpd -y
yum install php.x86_64 -y

157 systemctl start httpd.service ##开启httpd服务
158 systemctl enable httpd
159 systemctl stop firewalld.service ##关闭火墙
160 systemctl disable firewalld
2. 需要下载
162 phpMyAdmin-3.4.0-all-languages.tar.bz2 #### 压缩包
163 tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html
####解压压缩包到/var/www/html
164 mv phpMyAdmin-3.4.0-all-languages/ mysqladmin
#### 将安装包下的所有文件移动到 mysqladmin
165 cd mysqladmin
166 cp -p config.sample.inc.phpconfig.inc.php ###复制配置文件
167 vim config.inc.php ###写配置文件

$cfg['blowfish_secret'] = 'mysql';/* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

168 systemctl restart httpd
3.测试
访问
173 http://172.25.254.144/mysqladmin


数据 用户 密码 数据库 查询 配置 备份 字段 服务 登陆 内容 名字 文件 权力 网络 更新 中表 服务器 进程 加密 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 云服务器如何搭建vpn 关于网络安全视频2分钟英文 济南云越网络技术有限公司 网络安全实战攻防演习成果展示 手机app软件开发行业利润 股票软件开发山东 如何做好企业的网络安全防护工作 数据库技术概论关系图 新乡中起网络技术有限公司 戴尔网络安全模式更改账户密码 邯郸工控软件开发服务费 网络安全waf 数据库登录一直显示在连接 oracle数据库产品盘点 昆山爱图客软件开发有限公司 济宁慧与软件开发包分工作吗 山东省网络安全管理处罚裁量标准 怀旧服哪个服务器刷副本快 无锡网络安全宣传周金融日 数据库系统分析师面试题 昆明专业的网络安全机构 关于网络安全视频2分钟英文 软件开发工具公司有哪些 网络安全设备厂家特点 pdrr网络安全模型论文 绝对演绎怎么注销服务器 数据库应用技术教程微课版答案 UE设计在软件开发什么阶段 华为软件开发大会 致辞 渝北软件开发报价
0