# Don't enter mysql, Then enter the following command Export data from a library
mysqldump -u root -p tlxy > ~/Desktop/code/tlxy.sql
Export all data in a library , It will form a table creation and statement addition sql After the file, you can use this sql File to another library , Or create or reply to these data in this machine
# Don't enter mysql, Then enter the following command Export the data of the specified table in a library
mysqldump -u root -p tlxy tts > ~/Desktop/code/tlxy-tts.sql
# In the new database Import backup data , Import and export sql file
mysql -u root -p ops < ./tlxy.sql
mysql -u root -p ops < ./tlxy-tts.sql
mysql Medium root The user is the most privileged user in the database , Never use it in a project .
It can be given to different users , Or the project , Create different mysql user , And appropriate authorization , Complete the database operation . In this way, the security of the database is guaranteed to a certain extent .
grant Authorized operations on Authorized Library . Authorized form to Account @ The login address identified by ‘ password ’;
Example :
# stay mysql in Create a zhangsan user , Authorization can be made to tlxy All the tables in this library Conduct Add and query Authority
grant select,insert on tlxy.* to [email protected]'%' identified by '123456';
# user lisi. password 123456 It can be done to tlxy All the tables in the library have All operation rights
grant all on tlxy.* to [email protected]'%' identified by '123456';
drop user 'lisi'@'%';