MySQL database and the use of some common commands

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.