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

Mariadb database

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

# # configuring Network

Vim/etc/sysconfig/network-scripts/ifcfg-eth0 writes network configuration files

Systemctl restart network restarts the network

# # configuring yum Source

Vim / etc/yum.repos.d/rhel_dvd.repo write yum source configuration file

Yum clean all resets yum source

# # modify the server name

Hostnamectl set-hostnamemariadb.westos.com changes the local server name

Hostname view the local server name

# mariadb Database # Database manufacturer mysql oracle

Installation and configuration of a database

1 yum install mariadb-server-y # # install mariadb

2 systemctl start mariadb # # enable mariadb service

3 mysql # enter mysql database

4 netstat-antlpe | grep mysql # query mysqul

5 configuration file for vim / etc/my.cnf # mysqul

Skip-networking=1

6 systemctl restart mariadb # restart mariadb service

7 netstat-antlpe | grep mysqul

8 mysql

9 mysql_secure_installation # mysql security content configuration

(1) Enter current password for root (enter for none): [Enter]

(2) Set root password? [Y/n] Y

New password: # enter a new password

Re-enter new password: # confirm password

(3) Remove anonymous users? [Y/n] Y

(4) Disallow root login remotely? [YPao] Y

(5) Remove test database and accessto it? [Y/n] Y

(6) Reload privilege tables now? [YPao] Y

10 mysql-uroot-p

11 mysql

Figure:

2. Basic statements of database

1 landing

(1) mysql-uroot-pqwer1234 # # qwer1234 is a password

(2) mysql-uroot-p

Enter password: # # password is not displayed; high security performance

2 query

(1) show databases; # display database

(2) use mysql # enter the mysql library

(3) show tables; # displays the name of the table in the current library

(4) select * from user # query all the contents of the user table (* can be replaced with all the fields in the table)

(5) the structure of the desc user; # # query table (showing the names of all fields)

(3) Establishment of database and table

(1) create database westos; # create a westos library

Show databases; # display database

(2) use westos # enter the westos library

Create table linux (# # Linux table

-> username varchar (15) not null

-> password varchar (15) not null); the # # table contains two fields of username,password; the maximum length of characters is 15, and none of them is empty. (character length can be changed as needed)

Desc linux; # query the structure of the table (showing the names of all fields)

(3) insert into linux values ('user','123'); # insert data into the table

Select * from linux; # query everything in the linux table

Insert into linux values ('user1',password (' 123'))

# insert data into the table and encrypt the password

4 update database information

(1) update linux set password= ('234') where username='user1'

# Update the password of user1

Select * from linux; # query everything in the linux table

(2) update linux set password=password ('123') where username='user'

# update the password of use and encrypt

Select * from linux

3) alter table linux add age varchar (4)

# add the age field to the last column of the table

Select * from linux

(4) alter table linux add exam varchar (4) after password

# add the exam field to the specified location

Select * from linux

(5) alter table linux drop exam; # Delete the exam field in linux

Select * from linux

(6) update linux set password=password ('123') where (username='user' or username='user1')

# update and encrypt the passwords of two users

Select * from linux

5 backup of database

2 mysqldump-u root-pqwer1234-- all-database

# backup all data in all tables

3 mysqldump-u root-pqwer1234-- all-database-- no-data

# back up all tables, but not data

4 mysqldump-u root-pqwer1234 westos

# backup westos library

5 mysqldump-u root-pqwer1234 westos > / mnt/westos.sql

# back up the westos library and save the data to / mnt/westos.sql

8 mysql-uroot-pqwer1234-e "create database westos;"

# create a westos library

9 mysql-u root-pqwer1234 westos

< /mnt/westos.sql ####把数据导入westos库 10 mysql -u root -pqwer1234 16 mysqldump -u root -pqwer1234 westos linux >

/ mnt/linux.sql

# back up the linux table in the westos library and save the data to / mnt/linux.sql

17 mysqldump-u root-pqwer1234 westos test > / mnt/test.sql

# back up the test table in the westos library and save the data to / mnt/test.sql

27 mysql-u root-pqwer1234-e "show tables from westos"

# display the name of the table in the westos library

28 mysql-u root-pqwer1234 westos

< /mnt/test.sql ####把test表中数据导入westos库 29 mysql -u root -pqwer1234 -e "show tables from westos" ###显示westos库中表的名字 6 数据库的删除 (1) 删除表中数据 delete from linux where username='username'; mysql -u root -pqwer1234 MariaDB [(none)]>

Usewestos # enter the westos library

MariaDB [westos] > select * fromlinux; # query everything in the linux table

Delete from linux whereusername='user1'; # Delete user1 data in linux table

Delete from linux whereusername='user'; # Delete user data in linux table

Select * from linux; # query everything in the linux table

(2) delete the table

Drop table linux

(3) Delete the library

Drop database westos

7 user authorization

(1) set up users

MariaDB [(none)] > create userlee@localhost identified by 'lee'

# create a user lee to log in locally

MariaDB [(none)] > create userlee@'%' identified by 'lee'

# create lee users and log in to the network

(2) user authorization

MariaDB [(none)] > grantinsert,update,delete,select on westos.test to lee@localhost

# Log in to lee for authorization

MariaDB [(none)] > grant selecton westos.* to lee@'%'

# Log in to lee and authorize

(3) View user rights

MariaDB [(none)] > show grantsfor lee@'%'

# View user rights

MariaDB [(none)] > show grantsfor lee@localhost;,

# View user rights

(4) remove user authorization rights

MariaDB [(none)] > revoke deleteon westos.test from lee@localhost

# remove user authorization rights

MariaDB [(none)] > show grantsfor lee@localhost; view permissions

(5) Delete users

MariaDB [(none)] > selectUser,Host from mysql.user; View users

MariaDB [(none)] > drop userlee@'%'; delete user

MariaDB [(none)] > selectUser,Host from mysql.user; View users

8 password modification

(1) Super user password is known.

Mysqladmin-uroot-p234 password lee # # change the super user password to lee

(2) Super user password forgotten

[root@mariadb mnt] # mysqld_safe--skip-grant-tables &

# enable mysql login interface and ignore authorization table

[root@mariadb mnt] # mysql # enter mysql

MariaDB [(none)] > selectUser,Host,Password from mysql.user

# View users and user passwords in mysql.user

MariaDB [(none)] > updatemysql.user set Password=password ('234') where User='root'; # # update superuser password information to 234

MariaDB [(none)] > select User,Host,Passwordfrom mysql.user

# View users and user passwords in mysql.user

MariaDB [(none)] > quit

[root@mariadb mnt] # fg

[root@mariadb mnt] # killall-9 mysqld_safe # close the mysqld_safe process

[root@mariadb mnt] # ps aux | grep mysql # filter all processes of mysql

[root@mariadb mnt] # kill-9 mysqlpid # close all processes in mysql

[root@mariadb mnt] # systemctl restart mariadb # restart the mariadb service

[root@mariadb mnt] # mysql-uroot-p234 # login test

3. Page management tools of database

1. Installation

156 yum install httpd php php-mysql-y # # install three installation packages for httpd php php-mysql

Yum install php-mysql.x86_64-y

Yum install httpd-y

Yum install php.x86_64-y

157 systemctl start httpd.service # # enable httpd service

158 systemctl enable httpd

159 systemctl stop firewalld.service # # close the fire wall

160 systemctl disable firewalld

two。 Need to download

162 phpMyAdmin-3.4.0-all-languages.tar.bz2 # compressed package

163C / var/www/html tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2-C

# decompress the package to / var/www/html

164 mv phpMyAdmin-3.4.0-all-languages/ mysqladmin

# move all files under the installation package to mysqladmin

165 cd mysqladmin

166 cp-p config.sample.inc.phpconfig.inc.php # copy configuration file

167vim config.inc.php # write configuration file

$cfg ['blowfish_secret'] =' mysql';/* YOU MUST FILL IN THIS FOR COOKIE AUTH! * /

168 systemctl restart httpd

3. test

Visit

173 http://172.25.254.144/mysqladmin

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