command:
mysqld install; the configuration database
net start mysql; start database
mysql -uroot -p; start the database as root, -p password after
mysql -uroot -h "IP address" -p; disposed remote connection
set password = password ( 'password'); Set Password
mysqladmin -u username -p password old password new password
show databases; showcase all of the database
show create table table name; see table structure (see the statement will create a table, including constraints, primary keys, etc.)
use database name; switching database name
show variables like '% chara%'; see current coding
- Temporary modification (executed on the client): set xxxx = utf8;
- Permanent solution: add a set xxxx = utf8 in my.ini;
- Real-time to solve the problem: create tables table name () charset = utf8;
create:
select user (); view current user
create database database name; create a database
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));
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
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.
Delete specific operations:
- drop user username @ '%'; delete account
- drop user username @ 'localhost'; delete user permissions
- drop database database name; delete the database
- drop table table name; drop table
Permissions:
- flush privileges; refresh permission
- grant all privileges on the database name * to user name @localhost identified by 'password'; authorization to a user database of all permissions
- Format: grant permission on the database * to username @ log on the host identified by "password";.
- grant select, update on the database name * to user name @localhost identified by 'password';
- the SELECT Grant, the Delete, Update, the Create, drop ON . to username @ "%" identified by "password"; authorized user has certain rights to all databases
- @ "%" Means that all non-local host authorization, not including localhost. (Localhost address is set to 127.0.0.1
- Authorization to localhost: add that grant all privileges on the database name * to user name @localhost identified by 'password'; can.
- show grants for 'root' @ 'localhost'; view the database specific to a user's privileges
- ALL ON GRANT . The TO
用户名
@127.0.0.1
the WITH GRANT OPTION; modify user permissions
View data:
- select database (); View current library
- select * from table name; all the data in Table View
- SELECT DISTINCT CONCAT ( 'User:' '', user, '' '@' '', host, '' ';') AS query FROM mysql.user; see all users in the database
desc table; / describe table name; see table structure
insert into table values (data); add data table
update table set password = 'alex3714' where num = 1; updating data
delete from table name where num = 1; delete data table,
Permissions:
- usage: use rights
- select: View data
- update: update
- insert: write
- delete: Clear data
- all: All permissions
- On the back with a table in the database
- (*) On behalf of all tables (databases. *)
Basic operation:
- Operation of the database
- create database database name; create a database name, with the specific meaning of the English name
- show databases; see how many databases
- use database name; switch databases
- select database (); View Library is currently located
- Operating table
- create table English table (num int, username char (12), password char (32));
- show tables; view the current number of table
- desc table; see table structure
- describe table name; see table structure
- alter table table name, modify the table name
- Operational data
- insert into table values (1, 'alex', '123'); must correspond
- select * from table name; all the data in Table View
- update table data set name = 'xxxxx' where num = 1; modified data
- delete from table name where num = 1; delete data