mariadb数据库从入门到精通

发布时间:2024年01月20日

mariadb数据库的安装以及安全初始化



一、实验前提

实验环境:yum仓库搭建好
mariadb 是当前流行的Mysql数据库的分支
Mysql原先SUN公司(java)被Orical收购了
Mysql开源免费,所以企业当中的核心数据库是Orical,其余是Mysql
mariadb是Mysql数据库的一个分支


二、mariadb数据库的安装

1.数据库的安装

[root@server15 ~]# yum serach mariadb

在这里插入图片描述

[root@server15 yum.repos.d]# yum install mariadb-server.x86_64 -y
[root@server15 yum.repos.d]# rpm -ql mariadb-server 
查看它在系统里面安装的东西
/var/lib/mysql  其中这个为它的数据目录
/etc/my.cnf.d/server.cnf 主配置文件
/usr/lib/systemd/system/mariadb.service 服务的启动脚本
[root@server15 yum.repos.d]# systemctl enable --now mariadb.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
启动服务
[root@server15 yum.repos.d]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> quit
Bye

三、mariadb数据库安全初始化

由于数据库的登陆不需要密码所以不安全,我们要安全初始化。


3.1 设定数据库基本的安全初始化

[root@server15 yum.repos.d]# mysql_secure_installation  初始化脚本
Enter current password for root (enter for none):   当前数据库管理员的密码,无密码直接回车
Set root password? [Y/n] Y                   设定数据库管理员密码
New password: 
Re-enter new password: 
Password updated successfully!
 ... Success!
Remove anonymous users? [Y/n] y   
 ... Success!         移除匿名用户登陆
Disallow root login remotely? [Y/n] y  
 ... Success!         移除管理员远程登陆
Remove test database and access to it? [Y/n] Y 
 ... Success!         移除测试库
Reload privilege tables now? [Y/n] y    
 ... Success!         刷新数据库

密码登陆

[root@server15 yum.repos.d]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> quit
Bye

默认情况下数据库对外开放端口,开放了,容易被攻击。一般在企业中要关闭

[root@server15 yum.repos.d]# netstat -antlupe | grep mysql
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      27         31978      3768/mysqld     

3.2关闭对外开放端口

[root@server15 yum.repos.d]# vim /etc/my.cnf.d/server.cnf 
编辑主配置文件

在这里插入图片描述
关闭数据库网络端口

当设定完成后端口关闭

[root@server15 yum.repos.d]# systemctl restart mariadb.service 
[root@server15 yum.repos.d]# netstat -antlupe | grep mysql

END

系列文章目录

数据库的查询2


一、查看数据库

[root@server15 mnt]# mysql -uroot -p
MariaDB [(none)]> SHOW DATABASES; 查看有什么库
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

二、进入库并且查看数据库中的表

MariaDB [(none)]> USE mysql;      进入这个库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> SHOW TABLES;    查看表
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

三、查看数据库里所有表的名字

MariaDB [mysql]> SHOW TABLES FROM mysql;
查看mysql库里面所有表的名字

四、查看数据库里所有表的名字

MariaDB [mysql]> SELECT * FROM user;
查看user表里面的所有内容

在这里插入图片描述

4.1表里面的字段

表里面的字段
在这里插入图片描述

4.2查看表里面的字段

MariaDB [mysql]> SELECT Host,User,Password FROM user;
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |
| 127.0.0.1 | root | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |
| ::1       | root | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |
+-----------+------+-------------------------------------------+
3 rows in set (0.00 sec)

查看表里面的字段可以接条件

MariaDB [mysql]> SELECT Host,User,Password FROM user WHERE User='root' and Host='localhost';
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)

.表示分级

MariaDB [(none)]> SELECT Host,User,Password FROM mysql.user WHERE User='root' and Host='localhost';
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)

END

系列文章目录

数据库的建立3


一、新建一个库

[root@server15 mnt]# mysql -uroot -p
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> CREATE DATABASE westos;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| westos             |
+--------------------+
4 rows in set (0.00 sec)

二、新建一个表

MariaDB [(none)]> USE westos;
Database changed
MariaDB [westos]> SHOW TABLES;
Empty set (0.00 sec)
MariaDB [westos]> CREATE TABLE westos.linux (
    -> username varchar(6) not null,
    -> password varchar(30) not null
    -> );
Query OK, 0 rows affected (0.44 sec)

MariaDB [westos]> SHOW TABLES;
+------------------+
| Tables_in_westos |
+------------------+
| linux            |
+------------------+
1 row in set (0.00 sec)

三、查看表的结构

MariaDB [westos]> DESC westos.linux;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(6)  | NO   |     | NULL    |       |
| password | varchar(30) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

四、给表里面插入数据

MariaDB [westos]> INSERT INTO westos.linux VALUES ('lee',123)
    -> ;
Query OK, 1 row affected (0.04 sec)

MariaDB [westos]> DESC westos.linux;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(6)  | NO   |     | NULL    |       |
| password | varchar(30) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

MariaDB [westos]> SELECT * FROM westos.linux
    -> ;
+----------+----------+
| username | password |
+----------+----------+
| lee      | 123      |
+----------+----------+
1 row in set (0.00 sec)

五、同时向表中插入多个数据

MariaDB [westos]> INSERT INTO westos.linux VALUES ('lee1','123'),('lee2','123');
Query OK, 2 rows affected (0.40 sec)
Records: 2  Duplicates: 0  Warnings: 0

MariaDB [westos]> SELECT * FROM westos.linux
    -> ;
+----------+----------+
| username | password |
+----------+----------+
| lee      | 123      |
| lee1     | 123      |
| lee2     | 123      |
+----------+----------+
3 rows in set (0.00 sec)

END

系列文章目录

数据库密码的破解5


一、更改密码(知道原始密码)

[root@server15 mysql]# mysqladmin -uroot -p password 
Enter password: 
New password: 
Confirm new password: 

二、更改密码(不知道原先密码)

1.跳过授权表进入数据库

[root@server15 mysql]# mysqld_safe --skip-grant-tables & 
跳过授权表打开数据库 &后台运行
[2] 5479
[root@server15 mysql]# 210726 18:12:13 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
210726 18:12:13 mysqld_safe A mysqld process already exists
[root@server15 mysql]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

2.修改密码

在这里插入图片描述
3.更改里面的这个字段

在这里插入图片描述

MariaDB [(none)]> UPDATE mysql.user SET authentication_string=password('123') WHERE User='root';rhel8
MariaDB [(none)]> UPDATE mysql.user SET Password=password('123') WHERE User='root';   rhel7

4.查看mysql的所有进程并且关闭掉

[root@server15 mysql]# ps aux | grep mysql
root      5297  0.0  0.1 113312  1632 pts/0    S    18:10   0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql     5455  0.0  8.6 970848 88272 pts/0    Sl   18:10   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --skip-grant-tables --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root      5620  0.0  0.0 112708   972 pts/0    R+   18:20   0:00 grep --color=auto mysql
[root@server15 mysql]# kill -9 5297
[root@server15 mysql]# kill -9 5455
ps aux | grep mysql
root      5624  0.0  0.0 112708   976 pts/0    R+   18:22   0:00 grep --color=auto mysql 这个是grep的进程

5.更改完成

[root@server15 mysql]# systemctl start mariadb.service 
[root@server15 mysql]#  mysql -uroot -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 

END

系列文章目录

数据库密码的破解5


一、更改密码(知道原始密码)

[root@server15 mysql]# mysqladmin -uroot -p password 
Enter password: 
New password: 
Confirm new password: 

二、更改密码(不知道原先密码)

1.跳过授权表进入数据库

[root@server15 mysql]# mysqld_safe --skip-grant-tables & 
跳过授权表打开数据库 &后台运行
[2] 5479
[root@server15 mysql]# 210726 18:12:13 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
210726 18:12:13 mysqld_safe A mysqld process already exists
[root@server15 mysql]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

2.修改密码

在这里插入图片描述
3.更改里面的这个字段

在这里插入图片描述

MariaDB [(none)]> UPDATE mysql.user SET authentication_string=password('123') WHERE User='root';rhel8
MariaDB [(none)]> UPDATE mysql.user SET Password=password('123') WHERE User='root';   rhel7

4.查看mysql的所有进程并且关闭掉

[root@server15 mysql]# ps aux | grep mysql
root      5297  0.0  0.1 113312  1632 pts/0    S    18:10   0:00 /bin/sh /usr/bin/mysqld_safe --skip-grant-tables
mysql     5455  0.0  8.6 970848 88272 pts/0    Sl   18:10   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --skip-grant-tables --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root      5620  0.0  0.0 112708   972 pts/0    R+   18:20   0:00 grep --color=auto mysql
[root@server15 mysql]# kill -9 5297
[root@server15 mysql]# kill -9 5455
ps aux | grep mysql
root      5624  0.0  0.0 112708   976 pts/0    R+   18:22   0:00 grep --color=auto mysql 这个是grep的进程

5.更改完成

[root@server15 mysql]# systemctl start mariadb.service 
[root@server15 mysql]#  mysql -uroot -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 

END

系列文章目录

如何重新安装数据库6


重新安装数据库

企业中不能重新安装数据库

[root@server15 mysql]# systemctl stop mariadb.service 
[root@server15 mysql]# rm -fr /var/lib/mysql/
[root@server15 mysql]# yum reinstall mariadb-server.x86_64 -y
[root@server15 mysql]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 

END

系列文章目录

数据库的用户建立和授权7


一、查看数据库用户

MariaDB [(none)]> SELECT Host,User FROM mysql.user;
+-----------+------+
| Host      | User |
+-----------+------+
| 127.0.0.1 | root |
| ::1       | root |
| localhost | root |
+-----------+------+
只有管理员一个用户

二、数据库用户的建立

MariaDB [(none)]> CREATE USER westos@localhost identified by 'westos';
建立一个用户只能在数据库所在的主机上使用(此用户只能本机登陆数据库),‘’引号引起来的为密码
MariaDB [(none)]> CREATE USER westo@'%'identified by 'westos';
建立一个可以远程登陆的用户(此用户可以通过网络登陆数据库),能否使用要看数据库远程登陆端口打开没

建立成功

MariaDB [(none)]> SELECT Host,User FROM mysql.user;
+-----------+--------+
| Host      | User   |
+-----------+--------+
| %         | westo  |
| 127.0.0.1 | root   |
| ::1       | root   |
| localhost | root   |
| localhost | westos |
+-----------+--------+

三、删除数据库用户

删除用户

MariaDB [(none)]> DROP USER westo@'%';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SELECT Host,User FROM mysql.user;
+-----------+--------+
| Host      | User   |
+-----------+--------+
| 127.0.0.1 | root   |
| ::1       | root   |
| localhost | root   |
| localhost | westos |
+-----------+--------+
MariaDB [(none)]> 
[root@server15 ~]# mysql -uwestos -pwestos
MariaDB [(none)]> quit
[root@server15 ~]# mysql -uwestos -pwestos -h172.25.138.15
ERROR 2003 (HY000): Can't connect to MySQL server on '172.25.138.15' (111)
[root@server15 ~]# mysql -ulee -pwestos -h172.25.138.15
ERROR 2003 (HY000): Can't connect to MySQL server on '172.25.138.15' (111)

四、远程登录用户

我建立了一个远程登陆的用户lee

[root@server15 ~]# mysql -uroot -p
Enter password: 
MariaDB [(none)]> CREATE DATABASE westostest ;
MariaDB [(none)]> CREATE TABLE westostest.userlist (
    -> username varchar(10) not null,
    -> password varchar(30) not null
    -> );
MariaDB [(none)]> INSERT INTO westostest.userlist VALUES('lee','123'),('lee1','123');
MariaDB [(none)]> SELECT * FROM westostest.userlist;
+----------+----------+
| username | password |
+----------+----------+
| lee      | 123      |
| lee1     | 123      |
+----------+----------+

开启远程登陆接口

[root@server15 ~]# vim /etc/my.cnf.d/server.cnf 

在这里插入图片描述
注释掉这个
远程登陆

[root@server15 ~]# systemctl restart mariadb.service 
[root@server15 ~]# mysql -ulee -pwestos -h172.25.138.15
MariaDB [(none)]> 
[root@server15 ~]# mysql -uwestos -pwestos -h172.25.138.15
ERROR 1045 (28000): Access denied for user 'westos'@'server15' (using password: YES)

用westos用户登陆没有权限


五、没有权限

看不见表格

[root@server15 ~]# mysql -uwestos -pwestos
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> 

5.1授权查看

[root@server15 ~]# mysql -uroot -p
MariaDB [(none)]> GRANT SELECT ON westostest.* TO westos@localhost; westostest库里面所有表都可以查询.*
TO给westos@localhost这个用户
MariaDB [(none)]> SHOW GRANTS FOR westos@localhost;查看授权成功没
+---------------------------------------------------------------------------------------------------------------+
| Grants for westos@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'westos'@'localhost' IDENTIFIED BY PASSWORD '*28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96' |
| GRANT SELECT ON `westostest`.* TO 'westos'@'localhost'                                                        |
+---------------------------------------------------------------------------------------------------------------+
GRANT SELECT ON `westostest`.* TO 'westos'@'localhost'
授权成功

授权能够查看但无法插入

[root@server15 ~]# mysql -uwestos -pwestos
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| westostest         |
+--------------------+
MariaDB [(none)]> SELECT * FROM westostest.userlist;
+----------+----------+
| username | password |
+----------+----------+
| lee      | 123      |
| lee1     | 123      |
+----------+----------+
2 rows in set (0.00 sec)
MariaDB [(none)]> INSERT INTO westostest.userlist VALUES('test','123');
ERROR 1142 (42000): INSERT command denied to user 'westos'@'localhost' for table 'userlist'

5.2授权插入

[root@server15 ~]# mysql -uroot -p
MariaDB [(none)]> GRANT INSERT  ON westostest.* TO westos@localhost ;
MariaDB [(none)]> SHOW GRANTS FOR westos@localhost;
+---------------------------------------------------------------------------------------------------------------+
| Grants for westos@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'westos'@'localhost' IDENTIFIED BY PASSWORD '*28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96' |
| GRANT SELECT, INSERT ON `westostest`.* TO 'westos'@'localhost'                                                |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
插入和查看权限都有了
[root@server15 ~]# mysql -uwestos -pwestos
MariaDB [(none)]> INSERT INTO westostest.userlist VALUES('test','123');
Query OK, 1 row affected (0.04 sec)

5.3取消授权

[root@server15 ~]# mysql -uroot -p
MariaDB [(none)]> REVOKE INSERT ON westostest.* FROM westos@localhost;
MariaDB [(none)]> SHOW GRANTS FOR westos@localhost;
+---------------------------------------------------------------------------------------------------------------+
| Grants for westos@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'westos'@'localhost' IDENTIFIED BY PASSWORD '*28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96' |
| GRANT SELECT ON `westostest`.* TO 'westos'@'localhost'                                                        |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
[root@server15 ~]# mysql -uwestos -pwestos
MariaDB [(none)]> INSERT INTO westostest.userlist VALUES('test1','123');
ERROR 1142 (42000): INSERT command denied to user 'westos'@'localhost' for table 'userlist'

六、用户的所有权限

[root@server15 ~]# mysql -uroot -p
MariaDB [(none)]> SELECT * FROM mysql.user ;

在这里插入图片描述这个是所有权限比如:Select Insert Update …
在这里插入图片描述可以看到 root全是Y,所有权限都有
lee全是N没有任何权限

删掉用户

[root@server15 ~]# mysql -uroot -p
MariaDB [(none)]> DROP user westos@localhost;

END

系列文章目录

数据库的备份8


一、 数据库的备份

[root@server15 ~]# mysql -uroot -p
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| westostest         |
+--------------------+
[root@server15 ~]# mysqldump -uroot -pwestos mysql
它便会把mysql的库的内容用SQL语句输出到我们的屏幕上

节选很长一段sql语句
在这里插入图片描述
所以把它重定向,便可以保存下来

[root@server15 ~]# mysqldump -uroot -pwestos mysql > /mnt/mysql.sql

备份所有的库

[root@server15 ~]# mysqldump -uroot -pwestos --all-databases > /mnt/all.sql

只要备份库的结构不备份库中的数据

[root@server15 ~]# mysqldump -uroot -pwestos --all-databases --no-data > /mnt/all.sql
[root@server15 ~]# mysqldump -uroot -pwestos westostest > /mnt/westostest.sql
[root@server15 ~]# mysql -uroot -pwestos
MariaDB [(none)]> DROP DATABASE westostest;
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |

使用备份的库时先得建立库,才能导入


二、数据库的还原

使用备份的库时先得建立库,才能导入

[root@server15 ~]# mysql -uroot -pwestos -e "CREATE DATABASE westostest"
[root@server15 ~]# mysql -uroot -pwestos westostest < /mnt/westostest.sql

数据库还原成功

[root@server15 ~]# mysql -uroot -pwestos 
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| westostest         |
+--------------------+
MariaDB [(none)]> SELECT * FROM westostest.userlist;
+----------+----------+
| username | password |
+----------+----------+
| lee      | 123      |
| lee1     | 123      |
| test     | 123      |
+----------+----------+

END

系列文章目录

数据库的web界面管理器的部署9


数据库的web界面管理器的部署

可视化管理需要下载一个插件phpmyadmin
在这里插入图片描述
进入官网下载
我用的是3.4的版本,个人觉得好用

[root@foundation38 ~]# scp /var/run/media/kiosk/C6E6206CE6205EC5/phpMyAdmin-3.4.0-all-languages.tar.bz2 root@172.25.138.15:/mnt 
[root@server15 ~]# cd /mnt
[root@server15 mnt]# ls
all_nodata.sql  all.sql  mysql.sql  phpMyAdmin-3.4.0-all-languages.tar.bz2  westostest.sql

安装该插件

[root@server15 yum.repos.d]# yum install httpd php php-mysql.x86_64 -y
因为基于httpd发布,php默认不支持数据库,所以还得安装相应的插件让php支持数据库
[root@server15 yum.repos.d]# systemctl start firewalld.service 
[root@server15 yum.repos.d]# systemctl enable --now httpd
[root@server15 yum.repos.d]# systemctl restart httpd
[root@server15 yum.repos.d]# firewall-cmd --permanent --add-service=http
[root@server15 yum.repos.d]# firewall-cmd --reload

在这里插入图片描述

[root@server15 mnt]# yum install bzip2 -y
[root@server15 mnt]# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html/
[root@server15 mnt]# cd /var/www/html/
[root@server15 html]# ls
phpMyAdmin-3.4.0-all-languages
[root@server15 html]# mv phpMyAdmin-3.4.0-all-languages mysqladmin
改个名字要不然名字太长了,不好访问
[root@server15 html]# cd mysqladmin/
[root@server15 mysqladmin]# ls

在这里插入图片描述
软件的安装文档
在这里插入图片描述在这里插入图片描述

快速安装步骤

[root@server15 mysqladmin]# cp config.sample.inc.php config.sample.php

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
END

在这里插入图片描述

文章来源:https://blog.csdn.net/westos_yanzheng/article/details/135714614
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。