MySQL database FAQ summary:
1. Question about re-assigning the initial value of an auto-increment field?
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 *. * to xuys@192.168.88.234 1234 ";
Identified by "xuys
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 ');
Update db set host = '%' where user = 'xuys ';
Repeat steps 2nd and 3 above.
All of the above are common problems encountered during MySQL database operations. There are many other problems. Here we will not introduce them to you. This article is suitable for beginners to learn.