Summary of COMMON commands:
| 12345678910111213141516171819202122232425262728293031323334353637 |
create database name; Creating a database use databasename; selecting a database drop database name; Delete the database directly, do not remind show tables; display table describe tablename; table detailed description select plus distinct remove duplicate fields Show current MySQL version and current date select version (),current_date; Modify the password for root in MySQL: shell>mysql -u root -pmysql> update user set password=password ("Root123″) where user= ' root ' ; mysql> flush privileges Refresh Permissions mysql>use dbname; Open the database mysql>show databases; Show all Databases mysql>show tables; show all tables in MySQL database mysql>desc user; Display column information for the user table in the MySQL database grant create a Hyper-pipe account that can be connected from anywhere to the server and must be assigned a password mysql> grant all privileges on *.* to ' user_name ' @ ' localhost ' identified by ' password ' ; format:grant select on Database .* to user name @ Login host identified by password Delete Authorization: Mysql> revoke alL privileges on *.* from [email protected] "%"; mysql> delete from user where user= "root" and host= "%";mysql> flush privileges; Rename table: mysql > alter table t1 rename t2; Backup: mysqldump -hhostname - uusername -ppassword databasename > backup.sql; Recovery: mysql -hhostname - uusername -ppassword databasename< backup.sql; |
Here are two typical cases where MySQL 5.6 and MySQL 5.7 Install differences when initializing data. MySQL 5.6: When initializing the data, you need to go to the script directory of the home directory
Perform:
| 12 |
/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--datadir=/data/mysql--defaults-file=/etc/ MY.CNF--user=mysql |
The database password is empty at this time. MySQL 5.7: When initializing the data, it needs to be executed in the bin directory of the home directory:
| 12 |
/usr/local/mysql/bin/mysqld--user=mysql--datadir=/data/mysql--basedir=/usr/local/mysql/--initialize |
The operation to initialize the data using the mysql_install_db command has already been discarded. Note:--initialize will automatically generate a password in error log. If the plus--initialize-insecure password is empty
Use of MySQL database and some common commands