--Maintenance operations It's all operated under CMD.
To connect to a database :
Native: MySQL [-H-localhost]-u account-p
Remote: MySQL [-H remote_ip]-u account-p
Show all current databases: show databases;
Switch database: Use db_name;
Displays the table under the current database: show tables;
Authorized Remote access:
grant privileges on database. * To User name @ Login host identified by password (pwd_string);
is authorized to take effect:
Restart MySQL Service
Flush privileges;
Privileges:
Select,insert,...
Example : Authorizing Grand Select on studymysql.* to [email protected] ' 172.19.105.5 ' indentified by ' 123456 '
Update permissions flush privileges or restart MySQL set start MySQL
Exit Mysql:exit
To recover access rights :
Revoke privileges on database. * FROM user name @ login host;
--user management:
--New user
Create user User_name identified by ' Password_value ';
--Modify user
Rename user user_name to New_user_name;
Set password for user_name = password (' new_password ');
--delete user
drop user user_name[,user_name2,...];
--View users
Select User,host from Mysql.user;
--View online users
SELECT Substring_index (host, ': ', 1) as Host_short,
&NBSP ; Group_concat (DISTINCT user) as users,
COUNT (*) as Threads
&N Bsp from Information_schema.processlist
GROUP by Host_short
&NB Sp ORDER by COUNT (*), host_short;
--Create a database
Create DATABASE db_name [default character set UTF8 collate utf8_general_ci];
Example : Create DATABASE School default character set UTF8 collate utf8_general_ci;
--Delete Database
Drop database db_name;
Example : Drop Database School;
--Backing up the database
Mysqldump-u user_name-p db_name > Backupfile
Mysqldump-u user_name-p db_name [table_name]> backupfile
example : mysqldump-u root-p Employees > Employees.sql
--Restore Database
Mysql-u root-p
Determines whether the database to be restored exists, does not exist, creates
Switch to the database you want to restore
To perform a restore operation: source Backup.sql
example : 1.mysql-u root-p
2.show databases
3.creat databases Employees default character set UTF8
4.user Employees
5.source Employees.sql
--Programming
MySQL DCL Data Control language