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

Common operations of mysql database

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "common operations of mysql database", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "common operations of mysql database" bar!

Common actions of mysql (add users)

1.Mysql add user

Format: grant select on database. * to "user name" @ "login host" identified by "password"

Www.2cto.com

Example 1. Add a user's test1 password to abc, so that he can log in on any host and have the authority to query, insert, modify and delete all databases. First use the root user to connect to MYSQL, and then type the following command:

Grant select,insert,update,delete on *. * to "test1" @ "%" Identified by "abc"

Add all permission statements:

From example 1: the permission to execute (select,insert,....) Change to all privileges, which means that you have all the permissions, including the permission to create and delete the database, and it is no longer limited to operating www.2cto.com in one database.

GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' 123456'

Example 2, add a user's test2 password to abc, so that he can only log in on localhost, and can query, insert, modify and delete the database mydb (localhost refers to the local host, that is, the host where the MYSQL database is located), so that even if the user knows the test2 password, he can not access the database directly from the internet, but only through the web page on the MYSQL host.

Grant select,insert,update,delete on mydb.* to "test2" @ localhost identified by "abc"

two。 Query all users

The information of all users in mysql is stored in the mysql.user table.

Select user from mysql.user

Start and stop of 3.mysql service

Net stop mysql

Net start mysql

4. Log in to mysql

Syntax: mysql-u username-p user password-h host ip

Www.2cto.com

5. Show table structure

Describe table name

6. Export data

Mysqldump-u root-p database name-h IP address > f:/a.sql

7. Import data

Mysqldump-u root-p-- default-character-set=utf8 database name

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