当前位置:网站首页>Common commands of MySQL in Linux
Common commands of MySQL in Linux
2022-04-23 20:45:00 【Jan York】
Sign in

mysql -u user name -p
-- Then enter the password below ,Linux Your password will not show , Just hit blindly
mysql -u user name -p password
-- This method will log in directly
switch
Open database
service mysql start
I didn't put a semicolon here , If the terminal runs the command , Remember to add... At the end ; Otherwise, the following results may occur .

Close the database
service mysql stop
Restart the database
service mysql restart
Common operations
Show database list
show databases;
establish 、 Delete database
create database Database name ;
drop database Database name ;
Display the data table in the library
use mysql;
show tables;
Show data table structure
describe Data table name ;
Change Password
SET PASSWORD command ( Login required )
mysql> set password for user name @localhost = password(' New password ');
Use sql Statement update mysql In the library user surface ( Login required )
mysql> use mysql;
mysql> update user set password=password('123') where user='root' and host='localhost';
mysql> flush privileges;
mysqladmin command , Plaintext ( No login required )
mysqladmin -u user name -p Old password password New password
command , Ciphertext ( No login required )
mysqladmin -u user name -p Old password password+ enter , Then type the new password twice
Other commands
Import 、 Export database ( No login required )
Export all databases
mysqldump -u user name -p password --all-databases > export path
Export specified database
mysqldump -u user name -p password --databases Database name > export path
Export the structure of the specified database ( No data )
grammar :mysqldump -u user name -p password --no-data --databases Database name > export path
give an example :mysqldump -uroot -p123456 --no-data --databases testdatebase >/tmp/testdatebase_no_data.sql
Export the specified table in the specified database
grammar :mysqldump -u user name -p password --databases Database name --tables Data table name > export path
give an example :mysqldump -uroot -p123456 --databases testdatebase --tables t_user >/tmp/testdatebase_user.sql
Export the structure of the specified table in the specified database ( No data )
grammar :mysqldump -u user name -p password --no-data --databases Database name --tables Data table name > export path
give an example :mysqldump -uroot -p123456 --no-data --databases testdatebase --tables t_user >/tmp/testdatebase_user_no_data.sql
Export the specified table in the specified database , Set query conditions
grammar :mysqldump -u user name -p password --databases Database name --tables Data table name --where=' Conditions '> export path
give an example :mysqldump -uroot -p123456 --databases testdatebase --tables t_user --where='user_no=1'>/tmp/mysql_user_no.sql
Backing up databases across servers
-- take host1 In the server db1 All data from the database is imported into host2 Medium db2 In the database ,db2 The database of must exist or it will report an error
-- ( After testing , stay mysql5.5 In the version ,db2 To exist is to , The actual generated database name is the same as db1 Agreement ; add -C Parameter to enable compression passing )
grammar :mysqldump --host=host1 -u user name -p password --databases db1 |mysql --host=host2 -u user name -p password --databases db2
give an example :mysqldump --host=192.168.1.101 -uroot -p123456 -C --databases testdatebase |mysql --host=192.168.3.102 -uroot -p123456 --database testdatebase
adopt sql File import database
grammar :mysql -u user name -p password < Import path
give an example :mysql -uroot -p123456 < /tmp/testdatebase.sql
notes : Part from blog Garden
版权声明
本文为[Jan York]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232039375888.html
边栏推荐
- Leetcode 542, 01 matrix
- Leetcode 709, convert to lowercase
- pikachuxss如何获取cookie靶场,返回首页总是失败
- Unity ECS dots notes
- SQL: query duplicate data and delete duplicate data
- Matlab analytic hierarchy process to quickly calculate the weight
- Selenium 显示等待WebDriverWait
- 2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
- 41. 缺失的第一个正数
- go slice
猜你喜欢

浅谈数据库设计之三大范式

Some basic knowledge of devexpress report development
![[SQL] string series 2: split a string into multiple lines according to specific characters](/img/a2/835ff6f5593fae15c70104cfb19c42.png)
[SQL] string series 2: split a string into multiple lines according to specific characters

The ODB model calculates the data and outputs it to excel

Resolve the error - error identifier 'attr_ id‘ is not in camel case camelcase

上海回應“面粉官網是非法網站”:疏於運維被“黑”,警方已立案

Vulnhub DC: 1 penetration notes

内网渗透之DOS命令

go defer

DOS command of Intranet penetration
随机推荐
[PTA] get rid of singles
MySQL基础之写表(创建表)
一些接地气的话儿
LeetCode-279-完全平方数
打新债中签以后怎么办,网上开户安全吗
Another data analysis artifact: Polaris is really powerful
Commande dos pour la pénétration de l'Intranet
Leetcode 994, rotten orange
Plato farm is one of the four largest online IEOS in metauniverse, and the transaction on the chain is quite high
Send email to laravel
MySQL基础合集
电脑越用越慢怎么办?文件误删除恢复方法
UKFslam
LeetCode 1351、统计有序矩阵中的负数
go map
An error occurs when the addressable assets system project is packaged. Runtimedata is null
Communication between RING3 and ring0
Leetcode 542, 01 matrix
2021-09-02 unity project uses rider to build hot change project failure record of ilruntime
3-5通过XSS获取cookie以及XSS后台管理系统的使用