Get the App
SLTechnology News&Howtos  ›  Database  › 

Linux mysql backup Import

Shulou Source: shulou.com Published: 2022-06-01 10:31:23 10月03日 Update

Connect to remote linux database mysql-hIP-u username-p password

[root@localhost liuzhen] # mysql-h292.168.1.180-uroot-p123456

List what databases are available

Mysql > show databases

Create database create database xxx database name

Mysql > create database lmcmsv4.0

Toggle database use xxx database name

Mysql > use lmcmsv4.0

List all tables in the database

Mysql > show tables

Backup database

Mysqldump-hIP-u user name-p password database name > backup path

Mysqldump-h292.168.1.180-uroot-p123456 lmcms_160718 > / usr/local/119_sql_bak_liuzhen/119_lmcms_160718.2016-7-31.bak

Import database

The first way: mysql-hIP-u user name-p password database

< 备份地址 [root@localhost liuzhen]# mysql -h292.168.1.180 -uroot -p123456 lmcmsv4.0 < lmcmsv4.0.sql 第二种方式:source 备份地址 查看表结构 show create table cms_user; 授权 例1、增加一个用户user001密码为123456,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MySQL,然后键入以下命令: mysql>

Grant select,insert,update,delete on *. * to user001@ "%" Identified by "123456"

Example 2. Add a user's user002 password of 123456, so that this user can only log in on localhost, or set a specified IP, and query, insert, modify and delete the database test (localhost refers to the local host, that is, the host where the MySQL database is located).

In this way, even if the user knows the password of user_2, he cannot access the database directly from the Internet, and can only operate the test library through the MYSQL host.

First use the root user to connect to MySQL, and then type the following command:

Mysql > grant select,insert,update,delete on test.* to user002@localhost identified by "123456"

Tags: Data database user password backup host user name command address method for query login location permissions structure path switch Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MariaDB Shulou Tech Info Huawei Xiaomi