本文共 2104 字,大约阅读时间需要 7 分钟。
To start the MySQL service, use the following commands:
net start mysql
To stop the MySQL service, use:
net stop mysql
To access the MySQL database, use the following command:
mysql -u username -p
username
with your MySQL username.mysql -h ip_address -u username -p
To create a new user with specific permissions, use the grant
command:
grant select,insert,update,delete on *.* to newuser@localhost identified by "newpassword";
newuser
and newpassword
with your desired username and password.localhost
with %
to allow login from any machine.If you want to remove the password for a user:
grant select,insert,update,delete on mydb.* to newuser@localhost identified by "";
To view a list of available databases:
show databases;
mysql
and test
.To see the tables in a database:
use mysql;show tables;
To view the structure of a table:
describe table_name;
create database dbname;
drop database dbname;
use dbname;create table table_name (column_definitions);
drop table table_name;
insert into table_name values (data);
select * from table_name;
To clear all data in a table:
delete from table_name;
To create a backup:
mysqldump -u root -p dbname > backup.sql;
dbname
with the database you want to backup.For remote connections, use the following command:
mysql -h remote_ip -u root -p
remote_ip
with the target server's IP address.To exit the MySQL prompt:
exit
转载地址:http://nudfk.baihongyu.com/