For beginners, read MySQL database FAQs _ MySQL

Source: Internet
Author: User
For beginners, you must read the summary of MySQL database Frequently Asked Questions 1. Questions about auto-increment field re-assigning initial values?

Alter table tbl AUTO_INCREMENT = 1;

2. how to implement the function of adding fields in mysql?

Create table abc (id int (10) not null auto_incremnet primary key,

Name varchar (10) not null,

Address varchar (200) not null,

Postcode char (6) not null

);

In this way, a table is created, and the id sub-segment of the table increases automatically.

You can also add such fields to a created table as follows:

Alter table tb_name add id int (10) not null auto_increment first;

Or

Alter table tb_name add id int (10) not null auto_increment;

3. how do I change the user password in mysql?

A. In the mysql/bin/Directory

./Mysqladmin-u [user name, for example, root]-p [old password. leave it blank if there is no password] password [new password]

./Mysqladmin-uroot-p123456 password 456789

Username: root original password: 123456 New Password: 456789

B. enter mysql as the root user

Mysql> use mysql

Mysql> update user set Password = password ('newpassword') where User = 'root ';

Mysql> flush privileges;

Note the case sensitivity.

4. how to remotely connect to mysql

(1) go to mysql and create a new user, xuys:

Format: grant permission on database name. table name user @ login host identified by "user password ";

Grant select, update, insert, delete on *. *

Identified by "xuys1234 ";

View the result and execute:

Use mysql;

Select host, user, password from user;

You can see that the created xuys user already exists in the user table. The host field indicates the host to be logged on. The value can be an IP address or a host name. changing the value of the host field to % indicates that the host can be logged on to the mysql server as an xuys user on any client, we recommend that you set it to % during development.

Update user set host = '%' where user = 'xuys ';

(2) mysqladmin-uroot-ppwd reload

Mysqladmin-uroot-ppwd shutdown

(3)./mysqld_safe -- user = root &

Remember: any modification to the authorization table must be reload again, that is, step 1.

If you still cannot connect from the client after the preceding three steps, perform the following operations,

Insert a record in the db table of the mysql database:

Use mysql;

Insert into db values

('2017. 168.88.234 ',' % ', 'xuys', 'y ', 'Y', 'y', 'y ');

Update db set host = '%' where user = 'xuys ';

Repeat steps 2nd and 3 above.

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.