>  기사  >  일일 프로그램  >  현재 사용 가능한 데이터베이스를 다시 확인하세요.

현재 사용 가능한 데이터베이스를 다시 확인하세요.

angryTom
angryTom원래의
2019-10-24 10:17:197789검색

현재 사용 가능한 데이터베이스를 다시 확인하세요.

현재 데이터베이스를 다시 확인하세요

먼저 cmd를 열고 net start mysql을 입력하여 mysql 서비스를 시작한 다음 mysql -hlocalhost -uroot -p를 입력하고 Enter를 눌러 데이터베이스에 로그인합니다. 그런 다음 명령을 입력할 수 있습니다.

MySQL 명령줄에는 어떤 데이터베이스가 있는지 확인하려면 showdatabases; 명령을 사용하여 확인할 수 있습니다. 세미콜론을 잊지 않도록 주의하세요.

이전에 use mysql; 문을 사용했고 현재 데이터베이스를 다시 쿼리하려는 경우에도 show Databases; 명령을 사용하면 use test를 사용할 수 있습니다. 여기서 test는 전환하려는 데이터베이스의 이름입니다. 추천

"MySQL 동영상 튜토리얼"

일상적인 웹사이트 유지 관리에서 SQL문을 많이 사용하게 되는데, 능숙하게 사용하면 웹사이트 관리에 많은 이점이 있습니다. 특히 사이트 그룹을 관리할 때 다음과 같습니다. 명령줄에서 일반적으로 사용되는 MySQL 명령을 정리한 것이 도움이 되기를 바랍니다.

MySQL 명령줄에서 일반적으로 사용되는 18가지 명령

1. 데이터베이스 표시

show databases

테이블 표시

show tables;

2. 사용자 생성

비밀번호 123으로 루트 사용자 생성

use mysql;
grant all on *.* to root@'%' identified by '123' with grant option;
commit;

3.
grant all on *.* to xing@'localhost' identified by '123456' with grant option;
update user set password = password('newpwd') where user = 'xing' and host='localhost';
flush privileges;

4 , 데이터베이스 생성 testdb:

create database testdb;

5. 예방적 데이터베이스 생성:

create database if not testdb;

6. 테이블 생성:

use testdb;
create table table1(
username varchar(12),
password varchar(20));

7 예방적 테이블 생성:

create table if not exists aaa(ss varchar(20));

8.

describe table1;

9. 테이블 table1에 데이터 삽입:

insert into table1(username,password) values
('leizhimin','lavasoft'),
('hellokitty','hahhahah');
commit;

10. 테이블 table1 쿼리:

select * from table1;

11. 데이터 삭제:

update table1 set password='hehe' where username='hellokitty';
commit;

13.

delete from table1 where username='hellokitty';
commit;

14. 테이블 구조를 수정합니다.

쿼리에서 table1을 만듭니다.

alter table table1 add column(
 sex varchar(2) comment '性别',
 age date not null comment '年龄'
);
commit;

15. 테이블 table1을 삭제합니다.

create table tmp as
select * from table1;

16. 데이터베이스 testdb를 백업합니다.

drop table if exists table1;
drop table if exists tmp;

. 18. testdb 데이터베이스 복원

먼저 testdb 데이터베이스를 구축한 후 다음 명령을 사용하여 로컬 복구를 수행합니다.

mysqldump -h 192.168.3.143 -u root -p pwd -x --default-character-set=gbk >C:\testdb.sql

위 내용은 현재 사용 가능한 데이터베이스를 다시 확인하세요.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.