process
- Viewing the Version Number
show VARIABLES like '%version%'
Copy the code
- Backing up the Database
mysqldump -uroot -p --default-character-set=utf8 --databases mydatabase >d:\back.sql
Copy the code
- Import data
mysql -uroot -p mydatabase < d:\back.sql
Copy the code
- Mysql > select * from mysql;
mysql -uroot -p
show databases;
Copy the code
Root forgets password
-
Windows environment
- Close the service
net stop mysql Copy the code
Or turn it off in service
- Create password text file mysql-init. TXT
alter user 'root'@'localhost' identified by 'newPassword'; Copy the code
- Open the file and go to the installation directory using init-file
mysql server\bin> mysqld.exe --init-file=c:\\mysql-init.txt Copy the code
- If mysql Installation Wizard is used, this parameter may be required
default-file
shell> mysqld- defaults to the file = "C: \ \ ProgramData \ \ MySQL \ \ MySQL Server 8.0 \ \ my ini" - init - file = C: \ \ MySQL - init. TXTCopy the code
- After the service is successfully started, the created text file can be deleted
-
Linux environment
To reset your password
Compare the data
- mysql
information-schema-tables
SELECT count(*) TABLES, table_schema FROM information_schema.TABLES where table_schema = 'databaseName' GROUP BY table_schema;Copy the code
reference
1. The mysql documentation