Beginners must read MySQL database FAQ Summary

Source: Internet
Author: User

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.

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.