In daily website maintenance and management, a lot of SQL statements are used. Here are some commonly used commands for your reference. 1. Display database 2. Create a user <br /> Create a root user with a password of 123 use mysql; grant all on *.* to root@'%' identified by '123' with grant option; commit; 3. Change password grant all on *.* to xing@'localhost' identified by '123456' with grant option; update user set password = password('newpwd') where user = 'xing' and host='localhost'; flush privileges; 4. Create a database testdb: create database testdb; 5. Preventive creation of database: create database if not testdb; 6. Create a table: use testdb; create table table1( username varchar(12), password varchar(20)); 7. Preventive creation of table aaa: create table if not exists aaa(ss varchar(20)); 8. View the table structure: describe table1; 9. Insert data into table1: insert into table1(username,password) values ('leizhimin','lavasoft'), ('hellokitty','hahhahah'); commit; 10. Query table table1: select * from table1; 11. Change data: update table1 set password='hehe' where username='hellokitty'; commit; 12. Deleting data: delete from table1 where username='hellokitty'; commit; 13. Add a column to the table: alter table table1 add column( sex varchar(2) comment 'Gender', age date not null comment 'age' ); commit; 14. Modify table structure Create a table table1 from the query: create table tmp as select * from table1; 15. Delete table table1: drop table if exists table1; drop table if exists tmp; 16. Back up the database testdb mysqldump -h 192.168.3.143 -u root -p pwd -x --default-character-set=gbk >C:\testdb.sql 17. Delete the database testdb drop database testdb; 18. Restore the testdb database <br /> First, create the testdb database, and then use the following command to perform local recovery mysql -u root -pleizhimin testdb <C:\testdb.sql These 18 MYSQL commands are often used by administrators in daily maintenance. Proficient use of these commands will make your work very easy. You may also be interested in:
|
<<: How to deploy Confluence and jira-software in Docker
>>: Detailed explanation of JS variable storage deep copy and shallow copy
Serve: # chkconfig --list List all system service...
The author of this article @子木yoyo posted it on hi...
Table of contents 1. Create a table 1.1. Basic sy...
There are some tags in XHTML that have similar fu...
Generally, when we use a table, we always give it...
As the number of visits to the company's webs...
Based on theories such as Saussure's philosop...
After the National Day holiday, did any of you fi...
1 Introduction Apache Storm is a free, open sourc...
This article example shares the specific code of ...
Environment: init_worker_by_lua, set_by_lua, rewr...
Table of contents aforementioned VARCHAR Type VAR...
This article shares the specific code for WeChat ...
Question. In the mobile shopping mall system, we ...