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 mariadb of [basic part]

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Installation of database

Yum install mariadb.x86_64 mariadb-server.x86_64-y

Turn off the firewall

Close the network port (no access from outsiders)

Netstat-antlpe | grep mysql

Vim / etc/my.cnf

Add the words of skip

Restart the database service

two。 Add a password to the database

Mysql_secure_installation (Select all Y)

Log in to mysql-uroot-pwestos (login database)

3. Database usage

USE mysql (enter the mysql database)

CREATE DATABASE weostos (set up westos database)

CREATE TABLE linux (

Username varchar (15) not null

Password varchar (15) not null); (create table, username,password field)

SHOW DATABASES; (display database)

SHOW TABLES; (display tables in the database)

DESC linux (displays the data structure of the linux table)

SELECT host,user,password FROM linux

(query host,user,password field in linux table)

SELECT * FROM linux (query all fields in the linux table)

4. Modification of database

INSERT INTO linux VALUES ('user1','passwd', 'age')

UPDATE linux SET username='test@163.com' WHERE age='20'

ALTER TABLE linux add sex varchar (4)

(add sex field to linux table)

ALTER TABLE linux DROP sex; deletes the sex field

ALTER TABLE linux ADD sex VARCHAR (5) AFTER password (add sex after password)

DELETE FROM linux WHERE username='user1' (delete the line user1)

DROP TABLE westos.linux deletes tables in the library

DROP DATABASE westos deletes the westos library

5. Database password forgotten

Mysqladmin-uroot-pwestos password redhat

(known password change password)

Systemctl stop mariadb

Mysqld_safe-- skip-grant &

(skipping the grant-tables authorization table does not require authentication to log in to the local mysql database)

Mysql enters the database

Modify

Ps aux | grep mysql

Kill-9 3111 3269

Systemctl start mariadb

6. Backup of database

Mysqldump-uroot-pwestos westos (backup westos)

Mysqldump-uroot-pwestos-- all-databases (backup all libraries)

Mysqldump-uroot-pwestos westos > / mnt/westos.sql (backup westos to / mnt/)

Recovery of the database:

Mysql-uroot-pwestos-e "create database westos;" (create westos library)

Mysql-uroot-pwestos westos

< /mnt/westos.sql(恢复westos备份) 7.数据库用户的添加和访问权限 CREATE USER test@'localhost' identified by ' redhat ';(创建本地test用户) CREATE USER lee@'%'identified by 'redhat'; (创建网络用户,可以从远程任意主机登陆) GRANT SELECT on westos.* to lee@localhost; (给lee用户查看westos库的权限) GRANT ALL on *.* to lee@localhost; (给lee用户对于所有数据库的所有权限) SHOW GRANTS FOR lee@localhost; (查看lee用户的所有权限) GRANT SELECT,INSERT on westos.* to lee@localhost ( 给lee 在westos库的select和insert权限) REVOKE SELECT on westos.* FROM lee@localhost; (移除 lee用户在westos库的select权限) DROP USER lee@localhost;(删除lee用户) SELECT User FROM mysql.user;(查看系统中所有用户) 8.图形界面的数据库 1.安装httpd,php,php-mysql 关闭火墙 重启httpd 2.下载phpMyAdmin-3.4.0-all-languages.tar.bz2 tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html/ (指定解压后的位置) 3.mv phpMyAdmin-3.4.0- mysqladmin 改名 4.进入mysqladmin cp config.sample.inc.php config.inc.php 5.修改 config.inc.php 填写 'cookie'

You can access it with a browser. The graphical interface is a database.

Mysql-E (display by line)-N (do not show database)

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

Wechat

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

12
Report