MySQL usage notes

Source: Internet
Author: User

1. Install the client and server: mysql and mysql-server

2. Start the server:

Systemctl start mysqld. service # Start mysql Server systemctl enable mysqld. service # Make mysql server automatically run manual installation MySQL-server-5.6.10, there is no systemctl start file, you need to use service command: service mysql start/stop

3. Client Logon:

Mysql-h 110.110.110.110-u root-pabcd123

Mysql -- user = user_name-p

4. User Management:

Add User:

Reference: http://blog.csdn.net/shenyan008/article/details/8609446, Part 3

View All Users:

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

Change the common password:

Mysql-u root # log on to mysql

UPDATE user SET password = PASSWORD ("123") WHERE user = 'shenyan ';

Flush privileges;

Modify the root password:

Mysql> UPDATE mysql. user SET password = PASSWORD ('new password') WHERE User = 'root ';
Mysql> flush privileges;


View User Permissions:

Select * from mysql. user where user = 'cactiuser'

show grants for user-name

5. dump and recovery

Restore A database: mysql-h localhost-u root-p123456 database-name </tmp/xxx. SQL

Back up a database: mysqldump-h localhost-u root-p123456 database-name>/tmp/xxx. SQL


6. view the space occupied by each table in the MySQL database


Use information_schema
SELECT TABLE_NAME, DATA_LENGTH + INDEX_LENGTH, TABLE_ROWS from tables where TABLE_SCHEMA = 'database name' AND TABLE_NAME = 'table name'

7. mysql executes files containing SQL statements

Mysql> source file name

Related Article

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.