Mysql common commands are: 1. "create database name;"; 2. "use databasename;"; 3. "drop database name"; 4. "show tables;"; 5. "select version" etc.
Recommended: "mysql video tutorial"
##MySQL Common database commands
1. Common MySQL commandscreate database name; 创建数据库 use databasename; 选择数据库 drop database name 直接删除数据库,不提醒 show tables; 显示表 describe tablename; 表的详细描述 select 中加上distinct去除重复字段 mysqladmin drop databasename 删除数据库前,有提示。 显示当前mysql版本和当前日期 select version(),current_date;
shell>mysql -u root -p mysql> update user set password=password(”xueok654123″) where user=’root’; mysql> flush privileges //刷新数据库 mysql>use dbname; 打开数据库: mysql>show databases; 显示所有数据库 mysql>show tables; 显示数据库mysql中所有的表:先use mysql;然后 mysql>describe user; 显示表mysql数据库中user表的列信息);
mysql> grant all privileges on *.* to user@localhost identified by ’something’ with
格式:grant select on 数据库.* to 用户名@登录主机 identified by “密码” GRANT ALL PRIVILEGES ON *.* TO monty@localhost IDENTIFIED BY ’something’ WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO monty@”%” IDENTIFIED BY ’something’ WITH GRANT OPTION;
mysql> revoke all privileges on *.* from root@”%”; mysql> delete from user where user=”root” and host=”%”; mysql> flush privileges;
mysql >grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.com identified by ‘ passwd’
mysql > alter table t1 rename t2;
shell> mysqldump -h host -u root -p dbname >dbname_backup.sql
shell> mysqladmin -h myhost -u root -p create dbname shell> mysqldump -h host -u root -p dbname < dbname_backup.sql
shell> mysqladmin -u root -p -d databasename > a.sql
shell> mysqladmin -u root -p -t databasename > a.sql
mysqldump -T./ phptest driver
mysql > mysql -h myhost -u root -p database < sql.txt
The above is the detailed content of What are the common commands in mysql?. For more information, please follow other related articles on the PHP Chinese website!