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

Linux Notes 3-8 mysql

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

Share

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

* 8.Mysqlcards *

# # 1. Basic configuration # #

Installation

Yum install mariadb-y

Shut down the interface

The port used by Mariadb is open by default, so it must be insecure for the database, so we need to close the port

Edit the / etc/my.cnf file and add the following parameter to [mysqld]: skip-networking=1

Security configuration

Mysql_secure_installation / / enter the new password and enter all the way.

# # 2. Basic Operations # #

Landing

Mysql-u root-p

# # query # #

Show database SHOW DATABASES

Enter the database USE database_name

Display the table SHOW TABLES in the database

View data structure DESC table_name

Query information SELECT * FROM table_name

# # add # #

Add Library CREATE DATABASE database_name

Adding table CREATE TABLE table_name (...); / / not null indicates that it cannot be empty.

Add the attribute ALTER TABLE table_name ADD.. AFTER..

Add tuple INSERT INTO table_name VALUES ('..','..',...)

# # modify # #

Modify property UPDATE users SET class='2' WHERE name=''

# # Delete # #

Delete tuple DELETE FROM table_name WHERE...

Delete the attribute ALTER TABLE table_name DROP..

Delete table BROP TABLE table_name

Delete library DROP DATABASE database_name

# # 3. Users and access # #

Create a user

CREATE USER xx@localhost identified by 'hello'; / / create a local user

CREATE USER zz@'%' identified by 'hello'; / / create users who can log in everywhere

User authorizes GRANT INSERT,SELECT on *. * to xx@localhost

/ / add insert and select permissions to xx@localhost local users to all tables of all libraries

Overload authorization table FLUSH PRIVILEGES

View user Authorization SHOW GRANTS FOR xx@localhost

Revoke user rights REVOKE SELECT on *. * from xx@localhost

Delete user DROP USER xx@localhost

# # 4. Password Management # #

Forget the password

Systemctl stop mariadb// stops the mariadb service

Mysqld_safe-- skip-grant-tables & / / enter safe mode

Mysql-u root// login system

UPDATE mysql.user SET Password=password ('*') WHERE User=root

/ / set a new password

Fg / / transfer the process that enters the background to the foreground

Killall-9 mysqld_safe / / end the process

Ps aux | grep mysql / / View the process of mysql

Killall-9 3133 / / end the process

Modify the password

Mysqladmin-uroot-poldps password newps

# # 5. Backup and recovery # #

Mysqldump-uroot-pwestost linux > linux.sql / / backup linux library

Mysql-uroot-pwestos linux < linux.sql / / restore the linux library

# # 6. Graphical management # #

1. Install and configure httpd

two。 Install and configure myadmin

Download the phpadmin installation package from the network and put it in http's default release directory / var/www/html

And extract the file.

Put the package into a directory for easy access

Modify the configuration file according to the installation requirements

3. Install and configure php

4. Install the plug-in php-mysql

5. Add http to the firewall allow queue and restart the firewall

4. Restart network services

5. Now you can manage the database graphically.

Access in the browser:

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