operating MySql in cmd
Steps:
net start MySQL startup service
Mysql-uroot-ppassward Login Database
Mysql-h127.0.0.1-uroot-p logging on to a remote host
Exit Sign Out
Net stop MySQL shutdown service
Problems:
Start Service Promotion "Invalid service name"
Enter services.msc to see if the service list has a mysql service
Switch to mysql/bin directory input mysqld.exe-install Add service
If prompted install/remove of the service denide error, run cmd with the Administrator to try again
or run Mysqld.exe locally as an administrator , restart your computer and try again
in the Working with Mysql in Terminal
Steps:
Service mysqld start Services
Mysql-uroot-ppwd Login Database
Service mysqld Restart restart
Service mysqld Stop shutdown
User and Rights Management
Add Users: CREATE user ' made ' @ '% ' identified by ' password ';
Authorization command: GRANT all privileges the school.* to ' made ';
Grant Select Permission:Grant Select on school.* to ' made '% ';
deprivation of authority: REVOKE all privileges in school.* from ' made ' @ '% ';
Refresh Permissions Table: FLUSH privileges;
To Delete a user: DROP USER ' made ' @ '% ';
setting and changing user passwords
command : Set PASSWORD for ' username ' @ ' host ' = PASSWORD (' NewPassword '), if current user is logged in with set PASSWORD = PASSWORD (" NewPassword ");
example : SET PASSWORD for ' pig ' @ '% ' = PASSWORD ("123456");
Description: Privileges-user permissions for Operations,asSELECT, INSERT, UPDATEwait(For a detailed list, see the end of this article).If you want to grant the permission, use theAll .; DatabaseName-Database name, tablename-Table name,available if you want to grant the user appropriate permissions for all databases and tables*represents, as*.*.
example : GRANT SELECT, INSERT on Test.user to ' pig ' @ '% ';
GRANT all on * * to ' pig ' at '% ';
Note : a user authorized with the above command cannot authorize another user , and if you want the user to be authorized to do so , use the following command :
GRANT privileges on Databasename.tablename to ' username ' @ ' host ' with GRANT OPTION;
Operational Database:
Create
Create database name; (creating library)
The CREATE table [if not EXISTS] table name (
field 1 data type [ Field Properties | Constraints ] [ index ] [ note ],
field 2 data type [ Field Properties | Constraints ] [ index ] [ note ],
) [ table Type ] [ character set type ] [ note ]; (CREATE TABLE)
Delete
Drop database name; (Delete library)
Modify
ALTER TABLE old table name Rename [to] new table name;(rename)
Alter table name add field name data type [ properties ]; (add field)
Alter table name change original field name data type [ attribute ]; (modify field)
Alter table name drop field name;
View :
View Gallery: show databases;
Select library:use library name;
View all tables:show tables; (You need to check the library before executing)
View table:describe table name;
look at the table structure:desc table name;
Change and delete
Insert [into] table name [ column 1, column 2] VALUES ( value, value ); Insert
Delete table name [where]; Delete
Truncate table name ; (Delete all rows)
Update table name set column name = Updated value [where]; Change
Example:update students set age=age+5;(All age plus 5)
Select * from table name [where]; (query)
MySQL User and permissions operation