一..数据库的介绍
.什么是数据库
[root@westos_student50 mnt]# mount /iso/rhel-8.2-x86_64-dvd.iso /westos
[root@westos_student50 mnt]# dnf install mariadb-server.x86_64 安装
[root@westos_student50 mnt]# systemctl enable --now mariadb 开启
三..数据库安全初始化
![](https://i-blog.csdnimg.cn/blog_migrate/ab4c59672f598feb2ffabaaab3a54afb.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e580c31957595b54a6c657605afa0bc0.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2f164a1e61ea377953ad76d50f806210.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9293184674e8b2c2a170b0526fab0b92.png)
[root@westos_student50 Desktop]# systemctl restart mariadb.service
![](https://i-blog.csdnimg.cn/blog_migrate/0b920f78ba06f67da126fb308269d663.png)
四.数据库的基本管理
2.新建
3.更改
4.删除
五..数据密码管理
2.数据库密码破解
[root@westos_student50 Desktop]# systemctl stop mariadb 停止数据库服务
[root@westos_student50 Desktop]# mysqld_safe --skip-grant-tables & 跳过安全认证,并打入后台运行
[root@westos_student50 Desktop]# mysql 直接进入
[root@westos_student50 Desktop]# ps 查看进程
[root@westos_student50 Desktop]# killall -9 mysqld_safe 结束mysql进程
[root@westos_student50 Desktop]# ps aux | grep mysql 查看mysql进程
[root@westos_student50 Desktop]# kill -9 5689
[root@westos_student50 Desktop]# ps aux | grep mysql
[root@westos_student50 Desktop]# systemctl start mariadb 启动数据库服务
[root@westos_student50 Desktop]# mysql -uroot -pwestos
六.用户授权
[root@westos_student50 Desktop]# vim /etc/my.cnf.d/mariadb-server.cnf
[root@westos_student50 Desktop]# systemctl restart mariadb
七.数据库的备份
[root@westos_student50 Desktop]# mysqldump -uroot -pwestos --all-database 备份所有库
[root@westos_student50 Desktop]# mysqldump -uroot -pwestos --all-database --no-data 只备份库不要数据
[root@westos_student50 Desktop]# mysqldump -uroot -pwestos westos 备份westos库
[root@westos_student50 Desktop]# mysqldump -uroot -pwestos westos > /mnt/westos.sql
备份westos到westos.sql 里面
[root@westos_student50 Desktop]# mysql -uroot -pwestos -e "SHOW DATABASES;“ 在数据库外进行查看库命令
[root@westos_student50 Desktop]# mysql -uroot -pwestos -e "DROP DATABASE westos;"
在数据库外执行删除库命令
恢复库的方法
1).建立之后再将备份数据转入
[root@westos_student50 Desktop]# mysql -uroot -pwestos -e "CREATE DATABASE westos;"
[root@westos_student50 Desktop]# mysqldump -uroot -pwestos westos < /mnt/westos.sql
2). 编辑配置文件
[root@westos_student50 Desktop]# vim /mnt/westos.sql
[root@westos_student50 Desktop]# mysql -uroot -pwestos < /mnt/westos.sql
八.数据库图形化插件
安装Apache并且需要配置好网络连接:
解压并解档phpmyadmin压缩包,之后把压缩包删除并把解压后的目录重命名为mysqladmin:
把文件重命名 可以通过浏览器访问到数据库:
可以查看到新建的库test:
新建表名字并设置字段数:
新建表(结构):
可以查看到刚才建的表userlist: