Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Database management

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

{* database *}

1. Installation:

Yum install mariadb-server.x86_64-y installation service

Systemctl start mariadb enables the service.

Systemctl stop firewalld.service, close the fire wall.

Netstat-antlpe | grep mysql

Tcp 0 0 0.0.0.0 2565/mysqld 3306 0.0.0.0 2565/mysqld

Vim / etc/my.cnf

[root@server-dns ~] # systemctl restart mariadb.service

[root@server-dns ~] # netstat-antlpe | grep mysql

[root@server-dns ~] # mysql

Welcome to the MariaDB monitor. Commands end with; or\ g.

Your MariaDB connection id is 2

Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

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

MariaDB [(none)] > quit

Bye

Mysql-uroot-pwestos native login database

The first time mysql_secure_installation installs mysql, use this command to set up mysql

SHOW DATABASES; display database

USE mysql; enters the database

SHOW tables; displays tables in the database

DESC user; looks at the data structure in the user table

SELECT host,user,passwd FROM user; queries the host,user,passwd field in the user table

Flush privileges refresh database information

[root@server-dns ~] # mysql_secure_installation

/ usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

Password for the root user. If you've just installed MariaDB, and

You haven't set the root password yet, the password will be blank

So you should just press enter here.

Enter current password for root (enter for none): * * enter

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

Root user without the proper authorisation.

Set root password? [YBO] * * enter

New password: * * enter the password

Re-enter new password: * * confirm password

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

To log into MariaDB without having to have a user account created for

Them. This is intended only for testing, and to make the installation

Go a bit smoother. You should remove them before moving into a

Production environment.

Remove anonymous users? [YBO] * * enter

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

Ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [YBO] * * enter

... Success!

By default, MariaDB comes with a database named 'test' that anyone can

Access. This is also intended only for testing, and should be removed

Before moving into a production environment.

Remove test database and access to it? [YBO] * * enter

-Dropping test database...

... Success!

-Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

Will take effect immediately.

Reload privilege tables now? [YBO] * * enter

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB

Installation should now be secure.

Thanks for using MariaDB!

[root@server-dns ~] # systemctl restart mariadb.service * * restart the service and set it successfully

Mysql-uroot-predhat * * login

[root@server-dns] # mysql-uroot-predhat

Welcome to the MariaDB monitor. Commands end with; or\ g.

Your MariaDB connection id is 3

Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program 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 |

+-+

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

MariaDB [mysql] > SELECT Host,User FROM user

+-+ +

| | Host | User |

+-+ +

| | 127.0.0.1 | root |

| |:: 1 | root |

| | localhost | root |

+-+ +

3 rows in set (0.00 sec)

Create database logo; creates logo database

CREATE TABLE UTAB (username varchar (10) not null,passwd varchar (50) not null,age varchar (8) not null); create username,passwd,age field

MariaDB [mysql] > CREATE DATABASE logo

Query OK, 1 row affected (0.00 sec)

MariaDB [mysql] > SHOW DATABASES

+-+

| | Database |

+-+

| | information_schema |

| | logo |

| | mysql |

| | performance_schema |

+-+

4 rows in set (0.00 sec)

MariaDB [mysql] > SHOW TABLES logo

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'logo' at line 1

MariaDB [mysql] > USE logo

Database changed

MariaDB [logo] > CREATE TABLE UTAB (username varchar (10) not null,passwd varchar (50) not null,age varchar (8) not null)

Query OK, 0 rows affected (0.17 sec)

MariaDB [logo] > SHOW TABLES

+-+

| | Tables_in_logo |

+-+

| | UTAB |

+-+

1 row in set (0.00 sec)

MariaDB [logo] > DESC UTAB

+-+ +

| | Field | Type | Null | Key | Default | Extra | |

+-+ +

| | username | varchar (10) | NO | | NULL |

| | passwd | varchar (50) | NO | | NULL |

| | age | varchar (8) | NO | | NULL |

+-+ +

3 rows in set (0.00 sec)

MariaDB [logo] > SELECT * FROM UTAB

Empty set (0.00 sec)

MariaDB [logo] > INSERT INTOUTAB ('lee','123','20')

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near''lee','123','20')' at line 1

MariaDB [logo] > INSERT INTO UTAB VALUES ('lee','123','20')

Query OK, 1 row affected (0.07 sec)

MariaDB [logo] > SELECT * FROM UTAB

+-+

| | username | passwd | age | |

+-+

| | lee | 123 | 20 | |

+-+

1 row in set (0.00 sec)

MariaDB [logo] > INSERT INTO UTAB VALUES ('westos','123','')

Query OK, 1 row affected (0.07 sec)

MariaDB [logo] > SELECT * FROM UTAB

+-+

| | username | passwd | age | |

+-+

| | lee | 123 | 20 | |

| | westos | 123 |

+-+

2 rows in set (0.00 sec)

MariaDB [logo] > ALTER TABLE UTAB ADD AFTER password class varchar (8); insert class fields in the UTAB table

MariaDB [logo] > UPDATE UTAB SET class='1'; update class value is 1

MariaDB [logo] > UPDATE UTAB SET class='2' WHERE username='westos'

Update the value under the class field westos to 2

MariaDB [logo] > DELETE FROM UTAB WHERE username='westos'; deletes the westos in username

*. * represents all tables in the database

GREATE USER westos@'%' means that any database can be established (as long as the database port is open)

GREATE USER westos@'localhost' indicates that the native can create

SELECT * FROM mysql.user; needs to be queried under root users.

Note: authorization must be performed under the root user

Change the password (password is known)

Mysqladmin-uroot-predhat password westos modifies the local mysql root password

Database login password forgotten, reset password: (password unknown)

[root@server-dns ~] # systemctl stop mariadb

[root@server-dns] # mysqld_safe-- skip-grant-tables &

[1] 6344

[root@server-dns ~] # 161201 07:33:32 mysqld_safe Logging to'/ var/log/mariadb/mariadb.log'.

161201 07:33:32 mysqld_safe Starting mysqld daemon with databases from / var/lib/mysql

Reset password

[root@server-dns ~] # mysql-uroot

Welcome to the MariaDB monitor. Commands end with; or\ g.

Your MariaDB connection id is 1

Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

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

MariaDB [(none)] > UPDATE mysql.user set Password=password ('redhat'); * * set new password (redhat)

Query OK, 0 rows affected (0.00 sec)

Rows matched: 3 Changed: 0 Warnings: 0

MariaDB [(none)] > quit

Bye

[root@server-dns ~] # fg

Mysqld_safe-skip-grant-tables

^ Z

[1] + Stopped mysqld_safe-- skip-grant-tables

[root@server-dns] # killall-9 mysqld_safe

[1] + Killed mysqld_safe-- skip-grant-tables

[root@server-dns ~] # ps aux | grep mysql

Mysql 6499 0.0 5.1 859056 96752 pts/0 Sl 07:33 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 6657 0.0 112640 936 pts/0 R + 07:39 0:00 grep-color=auto mysql

[root@server-dns] # kill-9 6499

[root@server-dns ~] # ps aux | grep mysql

Root 6704 0.0 112640 936 pts/0 R + 07:40 0:00 grep-color=auto mysql

[root@server-dns ~] # systemctl start mariadb

[root@server-dns] # mysql-uroot-predhat * * login to change the password successfully

Welcome to the MariaDB monitor. Commands end with; or\ g.

Your MariaDB connection id is 2

Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

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

MariaDB [(none)] > quit

Database graphics management:

Yum install httpd-y

Systemctl status firewalld.service

Firewall-cmd-permanent-add-service=http

Firewall-cmd-reload

Systemctl start httpd

Cd / var/www/html/

Ls

Vim index.html

Lftp 172.25.254.250

Yum install lftp-y

Lftp 172.25.254.250

Ls

Tar-jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 extract the php installation package

Mv phpMyAdmin-3.4.0-all-languages myadmin rename (any name)

Yum install php-y install the php service

Systemctl restart httpd.service restart httpd

Cd myadmin/

Ls

Rpm-qa | grep php to view the php version

Rpm-qa | grep mariadb to view the mariadb version

Cp-p config.sample.inc.php config.inc.php

Vim config.inc.php

Yum install php-mysql.x86_64-y

Systemctl restart httpd.service

Search for 172.25.254.117/myadmin in the browser

Login user (root) password

Carry out operation

Send and receive email:

Configure dns first

Hostnamectl set-hostname maillinux.linux.com Server server

Vim / etc/sysconfig/network-scripts/ifcfg-eth0

Vim / etc/yum.repos.d/rhel_dvd.repo

Reboot

Yum install bind-y

Vim / etc/named.conf

# Generated by NetworkManager

Domain example.com

Search example.com linux.com

Nameserver 172.25.254.117

Vim / etc/named.rfc1912.zones

Cd / var/named/

Ls

Cp-p named.localhost westos.com.zone

Vim westos.com.zone

Cp-p westos.com.zone linux.com.zone

Vim linux.com.zone

Systemctl restart named

Vim / etc/resolv.conf

Systemctl stop firewalld.service

Systemctl restart named

Vim westos.com.zone

Cd

Systemctl restart named

Dig-t mx westos.com

Dig-t mx linux.com

1 hostnamectl set-hostname mailwestos.westos.com Server client

Vim / etc/sysconfig/network-scripts/ifcfg-eth0

Vim / etc/yum.repos.d/rhel_dvd.repo

Reboot

Vim / etc/resolv.conf

# Generated by NetworkManager

Domain example.com

Search example.com westos.com

Nameserver 172.25.254.117

Dig-t mx westos.com

Dig-t mx linux.com

Postconf-e "inet_interfaces=localhost" change

Vim / etc/postfix/main.cf

# myhostname = host.domain.tld-- > myhostname = host.domain.tld

# mydomain = domain.tld-- > mydomain = westos.com

# myorigin = $mydomain-- > myorigin = $mydomain

# inet_interfaces = all-- > inet_interfaces = all

Inet_interfaces = localhost-- > # inet_interfaces = localhost

Mydestination = $myhostname, localhost.$mydomain, localhost-- > mydestination = $myhostname, $mydomain, localhost

Systemctl restart postfix.service * * restart the service

Postqueue-f process the mail immediately

Vim generic

Postmap generic

Ls

Postconf-d | grep generic view default settings

Postconf-e "smtp_generic_maps = hash:/etc/postfix/generic" modification option

Systemctl restart postfix.service

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report