mariadb數(shù)據(jù)庫的安裝以及安全初始化
一、實驗前提
實驗環(huán)境:yum倉庫搭建好
mariadb 是當前流行的Mysql數(shù)據(jù)庫的分支
Mysql原先SUN公司(java)被Orical收購了
Mysql開源免費,所以企業(yè)當中的核心數(shù)據(jù)庫是Orical,其余是Mysql
mariadb是Mysql數(shù)據(jù)庫的一個分支
二、mariadb數(shù)據(jù)庫的安裝
1.數(shù)據(jù)庫的安裝
[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
查看它在系統(tǒng)里面安裝的東西
/var/lib/mysql 其中這個為它的數(shù)據(jù)目錄
/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數(shù)據(jù)庫安全初始化
由于數(shù)據(jù)庫的登陸不需要密碼所以不安全,我們要安全初始化。
3.1 設定數(shù)據(jù)庫基本的安全初始化
[root@server15 yum.repos.d]# mysql_secure_installation 初始化腳本
Enter current password for root (enter for none): 當前數(shù)據(jù)庫管理員的密碼,無密碼直接回車
Set root password? [Y/n] Y 設定數(shù)據(jù)庫管理員密碼
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! 刷新數(shù)據(jù)庫
密碼登陸
[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
默認情況下數(shù)據(jù)庫對外開放端口,開放了,容易被攻擊。一般在企業(yè)中要關閉
[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
編輯主配置文件
關閉數(shù)據(jù)庫網(wǎng)絡端口
當設定完成后端口關閉
[root@server15 yum.repos.d]# systemctl restart mariadb.service
[root@server15 yum.repos.d]# netstat -antlupe | grep mysql
END
系列文章目錄
數(shù)據(jù)庫的查詢2一、查看數(shù)據(jù)庫
[root@server15 mnt]# mysql -uroot -p
MariaDB [(none)]> SHOW DATABASES; 查看有什么庫
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
二、進入庫并且查看數(shù)據(jù)庫中的表
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)
三、查看數(shù)據(jù)庫里所有表的名字
MariaDB [mysql]> SHOW TABLES FROM mysql;
查看mysql庫里面所有表的名字
四、查看數(shù)據(jù)庫里所有表的名字
MariaDB [mysql]> SELECT * FROM user;
查看user表里面的所有內(nèi)容
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
系列文章目錄
數(shù)據(jù)庫的建立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)
四、給表里面插入數(shù)據(jù)
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)
五、同時向表中插入多個數(shù)據(jù)
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
系列文章目錄
數(shù)據(jù)庫密碼的破解5一、更改密碼(知道原始密碼)
[root@server15 mysql]# mysqladmin -uroot -p password
Enter password:
New password:
Confirm new password:
二、更改密碼(不知道原先密碼)
1.跳過授權表進入數(shù)據(jù)庫
[root@server15 mysql]# mysqld_safe --skip-grant-tables &
跳過授權表打開數(shù)據(jù)庫 &后臺運行
[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
系列文章目錄
數(shù)據(jù)庫密碼的破解5一、更改密碼(知道原始密碼)
[root@server15 mysql]# mysqladmin -uroot -p password
Enter password:
New password:
Confirm new password:
二、更改密碼(不知道原先密碼)
1.跳過授權表進入數(shù)據(jù)庫
[root@server15 mysql]# mysqld_safe --skip-grant-tables &
跳過授權表打開數(shù)據(jù)庫 &后臺運行
[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
系列文章目錄
如何重新安裝數(shù)據(jù)庫6重新安裝數(shù)據(jù)庫
企業(yè)中不能重新安裝數(shù)據(jù)庫
[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
系列文章目錄
數(shù)據(jù)庫的用戶建立和授權7一、查看數(shù)據(jù)庫用戶
MariaDB [(none)]> SELECT Host,User FROM mysql.user;
+-----------+------+
| Host | User |
+-----------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
+-----------+------+
只有管理員一個用戶
二、數(shù)據(jù)庫用戶的建立
MariaDB [(none)]> CREATE USER westos@localhost identified by 'westos';
建立一個用戶只能在數(shù)據(jù)庫所在的主機上使用(此用戶只能本機登陸數(shù)據(jù)庫),‘’引號引起來的為密碼
MariaDB [(none)]> CREATE USER westo@'%'identified by 'westos';
建立一個可以遠程登陸的用戶(此用戶可以通過網(wǎng)絡登陸數(shù)據(jù)庫),能否使用要看數(shù)據(jù)庫遠程登陸端口打開沒
建立成功
MariaDB [(none)]> SELECT Host,User FROM mysql.user;
+-----------+--------+
| Host | User |
+-----------+--------+
| % | westo |
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
| localhost | westos |
+-----------+--------+
三、刪除數(shù)據(jù)庫用戶
刪除用戶
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
系列文章目錄
數(shù)據(jù)庫的備份8一、 數(shù)據(jù)庫的備份
[root@server15 ~]# mysql -uroot -p
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| westostest |
+--------------------+
[root@server15 ~]# mysqldump -uroot -pwestos mysql
它便會把mysql的庫的內(nèi)容用SQL語句輸出到我們的屏幕上
節(jié)選很長一段sql語句
所以把它重定向,便可以保存下來
[root@server15 ~]# mysqldump -uroot -pwestos mysql > /mnt/mysql.sql
備份所有的庫
[root@server15 ~]# mysqldump -uroot -pwestos --all-databases > /mnt/all.sql
只要備份庫的結構不備份庫中的數(shù)據(jù)
[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 |
使用備份的庫時先得建立庫,才能導入
二、數(shù)據(jù)庫的還原
使用備份的庫時先得建立庫,才能導入
[root@server15 ~]# mysql -uroot -pwestos -e "CREATE DATABASE westostest"
[root@server15 ~]# mysql -uroot -pwestos westostest < /mnt/westostest.sql
數(shù)據(jù)庫還原成功
[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
系列文章目錄
數(shù)據(jù)庫的web界面管理器的部署9數(shù)據(jù)庫的web界面管理器的部署
可視化管理需要下載一個插件phpmyadmin
進入官網(wǎng)下載
我用的是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發(fā)布,php默認不支持數(shù)據(jù)庫,所以還得安裝相應的插件讓php支持數(shù)據(jù)庫
[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文章來源:http://www.zghlxwxcb.cn/news/detail-812376.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-812376.html
到了這里,關于mariadb數(shù)據(jù)庫從入門到精通的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!