1. Question about re-assigning the initial value of an auto-increment field?
ALTERTABLEtblAUTO_INCREMENT = 1;
2. How to Implement the function of adding fields in mysql?
Createtableabc (idint (10) notnullauto_incremnetprimarykey,
Namevarchar (10) notnull,
Addressvarchar (200) notnull,
Postcodechar (6) notnull
);
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:
Altertabletb_nameaddidint (10) notnullauto_incrementfirst;
Or
Altertabletb_nameaddidint (10) notnullauto_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-p123456password456789
Username: root original password: 123456 new password: 456789
B. Enter mysql as the root user
Mysql> usemysql
Mysql> updateusersetPassword = password ('newpassword') whereUser = 'root ';
Mysql> flushprivileges;
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 identifiedby "User Password ";
Grantselect, update, insert, deleteon *. * toxuys@192.168.88.234
Identifiedby "xuys1234 ";
View the result and execute:
Usemysql;
Selecthost, user, passwordfromuser;
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.
Updateusersethost = '%' whereuser = 'xuys ';
(2) mysqladmin-uroot-ppwdreload
Mysqladmin-uroot-ppwdshutdown
(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:
Usemysql;
Insertintodbvalues
('2017. 168.88.234 ',' % ', 'xuys', 'y ', 'y', 'y ');
Updatedbsethost = '%' whereuser = 'xuys ';
Repeat steps 2nd and 3 above.