国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

mariadb數(shù)據(jù)庫從入門到精通

這篇具有很好參考價值的文章主要介紹了mariadb數(shù)據(jù)庫從入門到精通。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

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

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,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 
編輯主配置文件

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
關閉數(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)容

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb

4.1表里面的字段

表里面的字段
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb

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.修改密碼

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
3.更改里面的這個字段

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb

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.修改密碼

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
3.更改里面的這個字段

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb

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 

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
注釋掉這個
遠程登陸

[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 ;

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb這個是所有權限比如:Select Insert Update …
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb可以看到 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語句
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
所以把它重定向,便可以保存下來

[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
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
進入官網(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

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb

[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

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
軟件的安裝文檔
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadbmariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb

快速安裝步驟

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

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb
END

mariadb數(shù)據(jù)庫從入門到精通,mariadb和oracle,數(shù)據(jù)庫,mariadb文章來源地址http://www.zghlxwxcb.cn/news/detail-812376.html

到了這里,關于mariadb數(shù)據(jù)庫從入門到精通的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • JAVA JDBC數(shù)據(jù)庫開發(fā)詳解:從入門到精通

    簡介: Java是一種面向?qū)ο?,安全靈活的編程語言,已經(jīng)成為了世界上最流行的編程語言之一。Java語言的一個重要應用領域就是數(shù)據(jù)庫開發(fā)。通過Java?JDBC(Java?Database?Connectivity)?API,開發(fā)人員可以使用Java語言來訪問并操作各種數(shù)據(jù)庫。 本篇資料將會詳細介紹Java?JDBC數(shù)據(jù)庫

    2024年02月02日
    瀏覽(24)
  • 13. python從入門到精通——Python操作數(shù)據(jù)庫

    13. python從入門到精通——Python操作數(shù)據(jù)庫

    python database API 規(guī)范對于關系數(shù)據(jù)庫的訪問,Python社區(qū)已經(jīng)制定出一個標準,稱為Python Database API,通過這個接口使python跨不同數(shù)據(jù)庫的操作代碼可以更加具有可移植性、讓 Python 可以連接(并操作)更多的數(shù)據(jù)庫。 用于管理數(shù)據(jù)庫連接的Connection(連接)對象 用于執(zhí)行查詢的

    2024年02月10日
    瀏覽(114)
  • MongoDB數(shù)據(jù)庫從入門到精通系列文章之:MongoDB數(shù)據(jù)庫百篇技術文章匯總

    MongoDB數(shù)據(jù)庫系列文章持續(xù)更新中: 更多數(shù)據(jù)庫內(nèi)容請閱讀博主數(shù)據(jù)庫專欄,數(shù)據(jù)庫專欄涵蓋了Mysql、SQLServer、PostgreSQL、MongoDB、Oracle、Cassandra等數(shù)據(jù)庫 數(shù)據(jù)庫專欄 文章名稱 文章鏈接 數(shù)據(jù)庫安裝部署系列之:部署Mongodb5.0.6高可用集群詳細步驟 數(shù)據(jù)庫安裝部署系列之:部署M

    2024年02月11日
    瀏覽(54)
  • Jmeter(六) - 從入門到精通 - 建立數(shù)據(jù)庫測試計劃(詳解教程)

    Jmeter(六) - 從入門到精通 - 建立數(shù)據(jù)庫測試計劃(詳解教程)

    1.簡介 ? 在實際工作中,我們經(jīng)常會聽到數(shù)據(jù)庫的性能和穩(wěn)定性等等,這些有時候也需要測試工程師去評估和測試,因此這篇文章主要介紹了jmeter連接和創(chuàng)建數(shù)據(jù)庫測試計劃的過程,在文中通過示例和代碼非常詳細地介紹給大家,希望對各位小伙伴和童鞋們的學習或者工作具有

    2024年02月13日
    瀏覽(20)
  • ASP.NET Core MVC 從入門到精通之數(shù)據(jù)庫

    ASP.NET Core MVC 從入門到精通之數(shù)據(jù)庫

    隨著技術的發(fā)展,ASP.NET Core MVC也推出了好長時間,經(jīng)過不斷的版本更新迭代,已經(jīng)越來越完善,本系列文章主要講解ASP.NET Core MVC開發(fā)B/S系統(tǒng)過程中所涉及到的相關內(nèi)容,適用于初學者,在校畢業(yè)生,或其他想從事ASP.NET Core MVC 系統(tǒng)開發(fā)的人員。 經(jīng)過前幾篇文章的講解,初步

    2023年04月27日
    瀏覽(25)
  • MySQL數(shù)據(jù)庫入門到精通1--基礎篇(MySQL概述,SQL)

    MySQL數(shù)據(jù)庫入門到精通1--基礎篇(MySQL概述,SQL)

    目前主流的關系型數(shù)據(jù)庫管理系統(tǒng): Oracle:大型的收費數(shù)據(jù)庫,Oracle公司產(chǎn)品,價格昂貴。 MySQL:開源免費的中小型數(shù)據(jù)庫,后來Sun公司收購了MySQL,而Oracle又收購了Sun公司。 目前Oracle推出了收費版本的MySQL,也提供了免費的社區(qū)版本。 SQL Server:Microsoft 公司推出的收費的中

    2024年02月07日
    瀏覽(21)
  • TiDB數(shù)據(jù)庫從入門到精通系列之四:SQL 基本操作

    成功部署 TiDB 集群之后,便可以在 TiDB 中執(zhí)行 SQL 語句了。因為 TiDB 兼容 MySQL,你可以使用 MySQL 客戶端連接 TiDB,并且大多數(shù)情況下可以直接執(zhí)行 MySQL 語句。 SQL 是一門聲明性語言,它是數(shù)據(jù)庫用戶與數(shù)據(jù)庫交互的方式。它更像是一種自然語言,好像在用英語與數(shù)據(jù)庫進行對

    2024年02月12日
    瀏覽(26)
  • Java從入門到精通24==》數(shù)據(jù)庫、SQL基本語句、DDL語句

    2023.8.27 數(shù)據(jù)庫是一個電子化儲存數(shù)據(jù)的系統(tǒng),它能夠以結構化形式組織、存儲和管理數(shù)據(jù),使得數(shù)據(jù)的訪問、操作和管理變得更為高效、可靠和安全 數(shù)據(jù)庫通常包括數(shù)據(jù)、數(shù)據(jù)結構、查詢語言、數(shù)據(jù)存儲和檢索引擎等多個組成部分,可分為關系型數(shù)據(jù)庫、非關系型數(shù)據(jù)庫等

    2024年02月11日
    瀏覽(51)
  • MariaDB數(shù)據(jù)庫服務器

    MariaDB數(shù)據(jù)庫服務器

    目錄 一、什么是數(shù)據(jù)庫? 二、什么是關系型數(shù)據(jù)庫? 三、數(shù)據(jù)庫字符集和排序規(guī)則是什么? 四、常用數(shù)據(jù)類型 五、Mariadb數(shù)據(jù)庫相關配置案例 一、什么是數(shù)據(jù)庫? 數(shù)據(jù)庫(DB)是以一定方式長期存儲在計算機硬盤內(nèi),能與多個用戶共享,具有盡可能小的冗余度、與應用程序

    2024年02月10日
    瀏覽(27)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包