数据库操作常用命令

MariaDB对外开放连接:

 

CREATE USER 'root'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;

 

 编辑/etc/mysql/my.cnf

#bind-address  = 127.0.0.1

mysql查看表结构命令,如下:

desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;

use information_schema
select * from columns where table_name='表名';

顺便记下:
show databases;
use 数据库名;
show tables;

创建数据库
create database abc;

 

删除数据库:

DROP DATABASE 数据库名;

 source 文件路径(注意要使用你所需要的数据库)

 

远程登陆MySQL,同时指定对应的端口和ip。

假设远程的ip为:10.154.0.43

端口为:3341

输入如下命令:

#mysql -uroot -p -h10.154.0.43 -P3341

回车后:

会需要输入密码。

开放mysql的外部访问权限

 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION

posted @ 2014-09-11 14:23  破冰Lab-Cookun  阅读(265)  评论(0编辑  收藏  举报