Installation, deletion, modification and query of database in linux

Keywords: MySQL MariaDB Database Linux

Installation and initialization of mariadb

yum install mariadb-server.x86_64 -y
systemctl status mariadb
systemctl start mariadb
systemctl enable mariadb
mysql
netstat -antlupe | grep mysql   See mysql port
vim  /etc/my.cnf
//Add skip networking = 1 skip network for security

systemctl restart mariadb			Restart service
mysql_secure_installation			Set user password, allow anonymous users to log in, load or not
Enter
123 Enter new password
123 Confirm password
Y
Y
Y
Y
Y
mysql                                           Can't sign in because a password is required
mysql     -uroot   -p	123                     root User login with password mysql	

Forget mysql password

systemctl stop mariadb.service                     close database
mysqld_safe --skip-grant-tables &                  Enter security into background login without password
mysql                                              Log in to the database
update mysql.user set Password=password('123456') where User='root';modify root The password is 123456
Ctrl-C                                             Logout
ps aux | grep mysql                                See mysql Related processes
kill -9 6003                                       End is end of secure login
kill -9 6158
systemctl restart mariadb.service                  Restart service
mysql                                              Unable to log on
mysql -uroot -p 123456                             root User new password login

Query of database

SHOW DATABASES; SHOW DATABASES
 USE library name; which library to enter
 SHOW TABLES; SHOW TABLES		
DESC table name; display table structure
 SELECT * FROM table name; display table information
 SELECT field 1, field 2,... from table name where field = 'field value'; query data

Database management

1)establish
CREATE  DATABASE  XXX;		Building library	
USE 	XXX;			Warehousing
CREATE TABLE Linux (id int,name varchar(10) not null, password varchar(10) not null);
desc Linux;                      Create table
INSERT INTO Linux values(1,'Tom','123');    insert data
2)change
UPDATE linux SET Password=passwrd('xue') where  username='xue';Change password ciphertext display
ALTER TABLE com RENAME  comptuer;                              Change table name
ALTER TABLE linux	ADD  class varchar(20);                Add to class This column
ALTER TABLE linux	DROP  class;                           delete class
3)delete
DELETE FROM redhat     where    username='xue';                
DROP     TABLE     redhat;
DROP     DATABASE  xaut;  
4)User authorization
CREATE USER xue@'localhost' identified by 'redhat';            establish xue The user password is redhat
GRANT SELECT,INSERT on xaut.* TO xue@localhost;    Authorized search insert to xue user xaut All tables below
SHOW GRANTS FOR xue@localhost;		                        View permissions granted by users
REVOKE  INSERT ON xaut.* FROM  xue@localhost;		        Withdraw user's insert permission

Graphical management

1 install and test the http service

yum install httpd

systemctl start httpd

systemctl enable httpd

systemctl status httpd

firewall-cmd --state

firewall-cmd --permanent  --add-service=http

firewall-cmd --reload 

firewall-cmd --list-all

cd /var/www/html/

vim index.html    hello world

2. Install php and php MySQL

3 download and install phpMyAdmin

4 decompress the file at / mnt/www/ftp tar jxf

5 renaming

6 enter phpMyAdmin directory

cp   config.sample.inc.php config.inc.php

 

Posted by DeadDude on Sat, 04 Jan 2020 11:44:08 -0800