MySQL set password, query Help, password back

Source: Internet
Author: User

Go to MySQL to find help: such as

Enter MySQL, authorize:

All privileges: All permissions

On *. *: All tables on all libraries

To that user @ that host

Set Password:

#mysqladmin-u root password ' 123456 '; Change Password: # mysqladmin-uroot-p123456 password 123;

Update the password inside the database:

mysql> Update Mysql.user set Password=password (123) where user= ' root ' and host= ' localhost '; Query OK, 1 row Affected (0.00 sec)

The refresh will not take effect until after the update.

Forgot Password: (use--skip-grant-tables to ignore authorization form)

Then use MySQL to log in to the database and reset the password:

Finally close the Mysqld_safe:

[Email protected] bin]# mysqladmin-uroot-p123456 shutdown

Then restart the MySQL service and log in with the updated password.



Query information in the database:

View the build statement: The default is the Latin character set;


The character set is not the same as the main culprit of database garbled.

If you use Utf_8 to specify a database, it is utf_8 when the library is created by default.

How to create a database in an enterprise?

1. Determine the character set according to the developed program (Utf_8 recommended)

2. Specifying a character set at compile time

--default Character=utf8

--default collate=utf_chinese_ci: Setting Character Set

3. Compile without specifying a character set or a different character set, how to solve?

Specifying a character set when creating a library



Authorized:

Mysql> Grant all privileges on * * to ' xpg ' @ '% ' identified by ' 123456 '; Query OK, 0 rows affected (0.04 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)


Index:

An index is like a book's directory, and if indexed on a field, it can speed up querying data when indexed as a query condition, which is one of the important elements of MySQL optimization.

Create a primary key index

Query the database, the fastest when you query by primary key, each table can have only one primary key column, but there may be multiple ordinary index columns, the primary key column requires that all the contents of the column must be unique, and the index does not require that the content must be unique.

The primary key is the primary key index, and the primary key index differs greatly from the normal index.

The first type:

Ways to create a primary key index:

Creates an index when the table is created.

Auto_increment: Self-increment

After setting the ID column as the primary key, name is the normal index.


mysql> create table user; error 1113  (42000):  a table must have at least 1 columnmysql > create table xog (    -> id int (4)  not null  auto_increment,    -> name char ( not null,  )   -> age int (4)  not null,    -> primary key ( ID),     -> key index_name (name)     -> ); query ok, 0 rows affected  (0.04 sec) mysql> desc xog;+-------+------ ----+------+-----+---------+----------------+| field | type     |  Null | Key | Default | Extra           |+-------+----------+------+-----+---------+----------------+| id  &nbsP; | int (4)    | NO   | PRI | NULL     | auto_increment | |  name  | char ( | NO   | MUL | NULL  )   |                | |  age   | int (4)    | NO   |      | NULL    |                 |+-------+----------+------+-----+---------+----------------+3 rows in  set  (0.01 SEC)

To back up the database:

-A: Backs up all databases,-B: Backs up the specified libraries, two cannot be

Mysqldump-uroot-p123456-b Test >/tmp/test.sql

About incremental Backups:

First of all, you must open the binary log write function, MySQL will be all the additions and deletions to the data into the binary library.

If you want to filter out a binary log of a library:


MySQL set password, query Help, password back

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.