Getting to the self-closing of Python - MySQL database operations command

command:
  1. mysqld install; the configuration database

  2. net start mysql; start database

  3. mysql -uroot -p; start the database as root, -p password after

  4. mysql -uroot -h "IP address" -p; disposed remote connection

  5. set password = password ( 'password'); Set Password

  6. mysqladmin -u username -p password old password new password

  7. show databases; showcase all of the database

  8. show create table table name; see table structure (see the statement will create a table, including constraints, primary keys, etc.)

  9. use database name; switching database name

  10. show variables like '% chara%'; see current coding

    1. Temporary modification (executed on the client): set xxxx = utf8;
    2. Permanent solution: add a set xxxx = utf8 in my.ini;
    3. Real-time to solve the problem: create tables table name () charset = utf8;
  11. create:

    1. select user (); view current user

    2. create database database name; create a database

    3. create table table name (field type (condition)); Create a table, the same field name can not

       create table demo(num int,username char(12),password char(32));
    4. insert into mysql.user (Host, User, Password) values ​​( "localhost", "username", password ( "Password")); localhost create a user account, the account can only log on locally, not another word ah on the machine remote Login

    5. insert into mysql.user (Host, User, Password) values ​​( "%", "username", password ( "Password")); create a account can log in on any computer, you can also specify a table the machine can log in remotely.

  12. Delete specific operations:

    1. drop user username @ '%'; delete account
    2. drop user username @ 'localhost'; delete user permissions
    3. drop database database name; delete the database
    4. drop table table name; drop table
  13. Permissions:

    1. flush privileges; refresh permission
    2. grant all privileges on the database name * to user name @localhost identified by 'password'; authorization to a user database of all permissions
    3. Format: grant permission on the database * to username @ log on the host identified by "password";.
    4. grant select, update on the database name * to user name @localhost identified by 'password';
    5. the SELECT Grant, the Delete, Update, the Create, drop ON . to username @ "%" identified by "password"; authorized user has certain rights to all databases
    6. @ "%" Means that all non-local host authorization, not including localhost. (Localhost address is set to 127.0.0.1
    7. Authorization to localhost: add that grant all privileges on the database name * to user name @localhost identified by 'password'; can.
    8. show grants for 'root' @ 'localhost'; view the database specific to a user's privileges
    9. ALL ON GRANT . The TO 用户名@ 127.0.0.1the WITH GRANT OPTION; modify user permissions
  14. View data:

    1. select database (); View current library
    2. select * from table name; all the data in Table View
    3. SELECT DISTINCT CONCAT ( 'User:' '', user, '' '@' '', host, '' ';') AS query FROM mysql.user; see all users in the database
  15. desc table; / describe table name; see table structure

  16. insert into table values ​​(data); add data table

  17. update table set password = 'alex3714' where num = 1; updating data

  18. delete from table name where num = 1; delete data table,

Permissions:
  1. usage: use rights
  2. select: View data
  3. update: update
  4. insert: write
  5. delete: Clear data
  6. all: All permissions
  7. On the back with a table in the database
  8. (*) On behalf of all tables (databases. *)
Basic operation:
  1. Operation of the database
    1. create database database name; create a database name, with the specific meaning of the English name
    2. show databases; see how many databases
    3. use database name; switch databases
    4. select database (); View Library is currently located
  2. Operating table
    1. create table English table (num int, username char (12), password char (32));
    2. show tables; view the current number of table
    3. desc table; see table structure
    4. describe table name; see table structure
    5. alter table table name, modify the table name
  3. Operational data
    1. insert into table values ​​(1, 'alex', '123'); must correspond
    2. select * from table name; all the data in Table View
    3. update table data set name = 'xxxxx' where num = 1; modified data
    4. delete from table name where num = 1; delete data

Guess you like

Origin www.cnblogs.com/heyulong1214/p/12069842.html