当前位置:网站首页>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
边栏推荐
- Latex formula
- SQL gets the latest record of the data table
- Unity Odin ProgressBar add value column
- [stack and queue topics] - sliding window
- LeetCode 1351、统计有序矩阵中的负数
- A login and exit component based on token
- On BIM data redundancy theory
- 电脑越用越慢怎么办?文件误删除恢复方法
- Preliminary understanding of cache elimination algorithm (LRU and LFU)
- Learn to C language fourth day
猜你喜欢
DOS command of Intranet penetration
Elastic box model
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
GO語言開發天天生鮮項目第三天 案例-新聞發布系統二
2021-09-02 unity project uses rider to build hot change project failure record of ilruntime
缓存淘汰算法初步认识(LRU和LFU)
LeetCode 74、搜索二维矩阵
What about laptop Caton? Teach you to reinstall the system with one click to "revive" the computer
Resolve the eslint warning -- ignore the warning that there is no space between the method name and ()
[matlab 2016 use mex command to find editor visual studio 2019]
随机推荐
LeetCode 542、01 矩阵
go struct
Linux中,MySQL的常用命令
LeetCode 232、用栈实现队列
Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case
Leetcode 709, convert to lowercase
Elastic box model
[PTA] get rid of singles
Recommended usage scenarios and production tools for common 60 types of charts
Automatically fill in body temperature and win10 task plan
又一款数据分析神器:Polars 真的很强大
2021-09-02 unity project uses rider to build hot change project failure record of ilruntime
Go zero framework database avoidance Guide
41. 缺失的第一个正数
SQL gets the latest record of the data table
Case of the third day of go language development fresh every day project - news release system II
XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
Queue template code
Thirty What are VM and VC?
SQL: query duplicate data and delete duplicate data