MySQL database commands

Source: Internet
Author: User
The following articles mainly describe the practical application of MySQL database commands, including how to correctly escalate the permissions of a user and how to obtain the actual recovery steps from the relevant backup files, the following describes the specific content of the article. I hope you will find some gains. 1: Enhance the permissions of a user. dbname: Specify the user grantallon *. * tosfsuse

The following articles mainly describe the practical application of MySQL database commands, including how to correctly escalate the permissions of a user and how to obtain the actual recovery steps from the relevant backup files, the following describes the specific content of the article. I hope you will find some gains. 1: Enhance the permissions of a user. dbname: Specify the user grantallon *. * tosfsuse

The following articles mainly describe the practical application of MySQL database commands, including how to correctly escalate the permissions of a user and how to obtain the actual recovery steps from the relevant backup files, the following describes the specific content of the article. I hope you will find some gains.

1. Enhance the permissions of a user

Dbname specifies the user

 
 
  1. grant all on *.* to sfsuser@'%';

2: Restore from the backup file

 
 
  1. MySQL-usfsuser-p111111 dbname <file path/file name;

3: log on to the remote MySQL database

 
 
  1. MySQL -h10.0.0.1 -usfsuser -p111111;

4: Set the default data Character Set

 
 
  1. vi /etc/my.cof

Find the client configuration [client] and add it below

Default-character-set = utf8 default character set: utf8

Add in [MySQLd]

Default-character-set = utf8 default character set: utf8

 
 
  1. init_connect='SET NAMES utf8'

Restart the MySQL database

 
 
  1. /etc/init.d/MySQL stop
  2. /etc/init.d/MySQL start

Enter MySQL to run

 
 
  1. show variables like 'character%';
  2. +--------------------------+----------------------------+
  3. | Variable_name | Value |
  4. +--------------------------+----------------------------+
  5. | character_set_client | utf8 |
  6. | character_set_connection | utf8 |
  7. | character_set_database | utf8 |
  8. | character_set_filesystem | binary |
  9. | character_set_results | utf8 |
  10. | character_set_server | utf8 |
  11. | character_set_system | utf8 |
  12. | character_sets_dir | /usr/share/MySQL/charsets/ |
  13. +--------------------------+----------------------------+

5. Slow query logs

In the MySQL database configuration file my. cnf, add

Log-slow-queries =/var/lib/MySQL/slowquery. log (specify the location where the log file is stored, which can be empty and the system will give a default file host_name-slow.log)

Long_query_time = 2 (including all 5. * series, before 5.1.21) Slow query logs are in seconds by default, and the time later than the millisecond record is 10 s by default)

Log-queries-not-using-indexes, if you want to enable the control, it is best to install the microtime slow query patch to avoid misunderstanding that some records are slow queries. for example, you can perform the count (*) operation on the entire table and other operations that do not use indexes but are fast)

Log-long-format (if it is set, all queries without indexes will be recorded)

After the database is restarted, use show variables to check whether the corresponding fields take effect;

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.