Turn on and off the MySQL service
Open and close the MySQL service under Windows
net start MySQL open MySQL service
net stop MySQL shutdown MySQL service
No restart of MySQL service this command
Linux under
Service MySQL Start | Stop | Restart | Status
- Start startup service
- Stop Stop Service
- Restart Restart Service
- Status View service state
Log in to MySQL database
Mysql-h Hostname-u Username-p
How to hostname is native, to be replaced by 127.0.0.1 or localhost
Example: Mysql-h localhost-uroot-p
This will change the line to let you lose the password, we can also write the password directly behind-p, of course, this is not safe.
Change root password
/usr/bin/mysqladmin-u root password ' 123456 '
After executing this command, the root password is changed to 123456.
Add a new user
Log into the database with root first
And then
MySQL > GRANT all privileges on * * to [email protected] identified by ' 123456 ' with GRANT OPTION;
Format: Grant permissions on database. * To User name @ login host identified by "password";
MySQL > Flush privileges; Refresh System Permissions Table
This is the most basic command, anyway there are a lot of options, this first as an understanding.
Modify Login Password
After logging into the database, you can
Set password = password (' 123456 ');
To change the password
To view all currently existing databases
show databases; Show out, more than one database here we're going to add s
Create a database
CREATE DATABASE database_name; Create is created, because only one database can be created at a time, where database does not add s, and then the name
View the created database
Show CREATE Database Database_name\g
If the database is created successfully, the database creation information is displayed
Deleting a database
DROP DATABASE database_name; Note that the drop is used instead of the delete
Use the drop database command to be particularly cautious when deleting all the data tables and data stored in the database in such a way that they are deleted together and cannot be recovered
The database management system uses the data engine to create, query, update, and delete data operations, and different storage engines provide different storage mechanisms, indexing techniques, locking levels, and other functions.
The core of MySQL is the storage engine.
View the storage engine for a database
Show Engines\g
The support column indicates whether an engine can be used, yes indicates that it can be used, no indicates that it is not available, and default indicates that the engine is the current default engine.
The common MySQL engines are:
Innodb,myisam,memory,merge,archive,federated,csv,blackhole
Select Current Database
Use database_name
View the default engine
Show variables like ' storage_engine ';
MySQL basic commands and operations