MySQL Application management common commands 1

Source: Internet
Author: User

8, Login mysqlmysql -urot -p   Single Instance Mysql -uroot -p -s /data/3306/mysql.sock    Multi-Instance 9, MySQL help command helpmysql> helpfor information about mysql products  and services, visit:   http://www.mysql.com/for developer information ,  including the mysql reference manual, visit:   http:// dev.mysql.com/to buy mysql enterprise support, training, or other  Products, visit:   https://shop.mysql.com/list of all mysql commands: note that all text commands must be first on line and  end with  '; '?           (\?)  Synonym for  ' Help ' .clear      (\c)  clear the current  input statement.connect    (\ r)  reconnect to the server. optional arguments are db and  host.delimiter  (\d)  Set statement delimiter.edit       (\e)  Edit command with  $EDITOR .ego        (\g)  send  command to mysql server, display result vertically.exit        (\q)  Exit mysql. Same as quit.go          (\g)  Send command to mysql server.help        (\h)  Display this help.mysql> show databases like  "my%"; +--- -------------+| database  (my%)  |+----------------+| mysql           |+----------------+1 row in set  (0.00 sec) mysql>  show grants for [email protected]; +---------------------------------------------------------------------+| grants  for [email protected]                                             |+------------------------------------ ---------------------------------+| grant all privileges on *.* to  ' root ' @ ' localhost '  with grant option | |  GRANT PROXY ON  ' @ '  TO  ' root ' @ ' localhost '  with grant option         |+------------------------------------------------------------ ---------+2 rows in set  (0.00 sec) mysql> grant all privileges  on *.* to [email protected] ' localhost '  identified by  ' 123456 '  with grant option; added system users and promoted to Super Administrator, that is, root-equivalent users, just different names mysql>  delete from mysql.user;    Delete all users in MySQL to set the password method for the root account [[email protected]  tools]# mysqladmin -uroot password  ' 123456 '      password-free user settings command [[email]  protected] tools]# mysqladmin -uroot -p ' 123456 '  password  ' 654321 '  -S  /data/3306/mysql.sock   for multi-instance modify administrator root password method 1[[email protected] tools]# mysqladmin  -uroot -p ' 123456 '  password  ' Martin ' [[Email protected] tools]# mysqladmin  -uroot -p ' 654321 '  password  ' Martin '  -S /data/3306/mysql.sock   For multi-instance modification Administrator root password method 2mysql> update mysql.user set password=password (' Martin ')  where  user= ' Root ';  mysql> flush privileges; the first password represents the field to be modified     The second password Representative is a function of this method suitable for password loss after  --skip-grant-tables parameter change password after starting database mysql> select user,host,password from mysql.user;+------ --+-----------+-------------------------------------------+| user   | host       | password                                    |+--------+-----------+-------------------------------------------+|  root   | localhost |                                             | |  root   | centos02  |                                             | |  root   | 127.0.0.1 |                                             | |  root   | ::1       |                                              | |         | localhost |                                             | |         | centos02  |                                              | |  system | localhost | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |+--------+----- ------+-------------------------------------------+mysql> update mysql.user set  Password=password (' Martin ')  where user= ' system ';       query ok,  1 row affected  (0.14 sec) rows matched: 1  changed: 1   Warnings: 0mysql> flush privileges; Query ok, 0 rows affected  (0.05 sec) mysql> quitbye[[email protected] tools]# mysql - Usystem -pmartinwelcome to the mysql monitor.  commands end with  ; or \g.your mysql connection id is 6server version: 5.5.49  MySQL Community Server  (GPL) copyright  (c)  2000, 2013, oracle and /or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql>  recover lost MySQL password 1, first stop the database [[email protected] tools]# /etc/init.d/ MYSQLD STOP2, using  --SKIP-GRANT-TABLES  start MySQL, ignore authorization login verification [[email protected] tools]# /application/mysql/bin/mysqld_safe -- Skip-grant-tables --user=mysql &[[email protected] tools]# mysql -uroot  -p  Login spatiotemporal password mysql> update mysql.user set password=password (' 123456 ')  where  user= ' root '  and host= ' localhost ';     #修改密码为123456              Query OK, 0 rows affected  (0.06  SEC) rows matched: 1  changed: 0  warnings: 0mysql> flush  privileges; query ok, 0 rows affected  (0.11 sec) [[email protected] tools]#  mysqladmin -uroot -p123456 shutdown    gracefully closes the database 160802 13:01:47 mysqld_ safe mysqld from pid file /application/mysql/data/centos02.pid ended[1]+   Done                     /application/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql[[email protected]  tools]# [[email protected] tools]# /etc/init.d/mysqld start  starting  mysql.                                              [  ok  ][[email protected] tools]#  mysql -uroot -p123456welcome to the mysql monitor.  commands  end with ; or \g.Your MySQL connection id is 1Server  version: 5.5.49 mysql community server  (GPL) copyright  (c)  2000, 2013,  oracle  and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql>  multiple instances to retrieve lost passwords killall mysqldmysqld_safe --defaults-file=/data/3306/my.cnf  --skip-grant-tables &mysql -uroot -p -S /data/3306/mysql.sock  Login spatiotemporal password Mysql> update mysql.user set password=password (' 123456 ')  where user= ' Root '  and host= ' localhost ';     #修改密码为123456              mysql> flush privileges;killall mysqld/data/3306/mysql  start



This article from "Thick tak" blog, declined reprint!

MySQL Application management common commands 1

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.