Home > Database > Mysql Tutorial > MySql基本操作一_MySQL

MySql基本操作一_MySQL

WBOY
Release: 2016-06-01 13:01:03
Original
1420 people have browsed it

MySql基本操作

本实例是在windows平台下命令行操作。
首先要在mysql数据库中新建一个超级管理员账号,结果登录mysql报错。
先总结一下mysql的基本操作(mysql根目录下的bin目录中操作):
(登录mysql username为账号名)

mysql -u username -p
Copy after login

(显示mysql中的数据库)

show databases;
Copy after login

(创建新的数据库)

create database [databaseName];
Copy after login

(确定使用哪个数据库,创建表、查看表)

use databaseName;
create table [tableName] (field1 type1,field2 type2...);
show tables;
Copy after login

(显示表的栏位)

describe tableName;
Copy after login

(删除表)

drop table [tableName];
Copy after login

(删除数据库)

drop database [databaseName];
Copy after login

(添加用户)

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘www’@'localhost’IDENTIFIED BY ’123456′ WITH GRANT OPTION;
Copy after login

(添加超级用户账户,用户名:www,密码:123456.具有完全的权限可以做任何事情。账户 (‘www’@’localhost’)只用于从本机连接)
e.g.

mysql> grant all privileges on *.* to 'tester' @'localhost' identified by 'tester' with grant option;
Query OK, 0 rows affected (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)


mysql> GRANT ALL PRIVILEGES ON *.* TO ‘www’@'%’IDENTIFIED BY ’123456′ WITH GRANT OPTION;
Copy after login

(添加超级用户账户,用户名:www,密码:123456.具有完全的权限可以做任何事情。账户 (‘www’@’%’)可用于从其它主机连接)
(删除账号)

drop user username...
Copy after login

e.g.

mysql> drop user tester @'localhost';
Query OK, 0 rows affected (0.00 sec)
Copy after login

参考链接:

MySQL用户账号管理(添加、删除、限制、设置密码、远程访问
基本操作

cmd命令行获得管理员权限

1.进目录:C:\Windows\System32下找到cmd.exe 右键以管理员身份运行
2.win8下,进metro界面点击右上角搜索,输入cmd,点击“以管留员身份运行”
3.直接打开cmd,输入

D:\mysql-5.6.19-winx64\bin>runas /user:adminitrator cmd
输入 adminitrator 的密码:
试图将 cmd 作为用户 "LWQ\adminitrator" 启动...
RUNAS 错误: 无法运行 - cmd
1326: 用户名或密码不正确。
Copy after login

然后根据提示输入adminitrator的密码就行了。遗憾的是我自己不知道adminitrator的密码。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template