1. 安装
2. 启动
service mysql start或者
/etc/rd.d/init.d/mysql start或者
mysqld_safe&或者
safe_mysqld&
步骤1:进入到
安装目录下面执行:
./mysqld_safe &启动mysql数据库
步骤2:
./mysql -uroot, 或者加入环境变量/etc/profile
export MySQL_HOME=/usr/local/mysql
export PATH=$MySQL_HOME/bin:$PATH
授权:
授权本地访问:
GRANT
ALL
PRIVILEGES
ON *.*
TO
'discuz'@
'localhost' IDENTIFIED
BY
'discuz'
WITH
GRANT
OPTION;
授权远端访问:
GRANT
ALL
PRIVILEGES
ON *.*
TO
'discuz1'@
'%' IDENTIFIED
BY
'discuz1'
WITH
GRANT
OPTION;
查看授权:show grants
create user, grant, phpmyadmin
revoke
update, mysqladmin
\s或者status
创建表 user的语句:show create table user
show grants;
password()函数
create user, grant, phpmyadmin
revoke
update, mysqladmin
\s或者status
创建表 user的语句:show create table user
show grants;
password()函数
3. 关闭
service mysql stop
/etc/rd.d/init.d/mysql stop或者
mysqladmin shutdown
4. 测试
(1)ping
mysqladmin ping
(2)版本
mysqladmin stop
(3)系统数据库mysql与测试数据库test
mysqlshow
6. 基本使用
show tables;
show databases;
use 数据库名;
desc user;
describle 表名;或 desc 表名;
'#', '--'均可用于注释
create database school;
drop database school;
drop database if exists school;
create table student #建立学生表
(
id int(5) auto_increment not null primary key,
name char(10) not null,
address varchar(50) default '清华大学'
year date
);
select left(address,10) from student; 只看address的前10个字符
select count(*) from student;统计记录数
select (100+98+99)/3;当计算器来用
select """hello";结果为"hello, 将2个双引号当做1个双引号
或select "\"hello";结果为"hello
select '''hello';结果为'hello
select '\'hello';结果为'hello
select 0xa+0; 结果为10
select 0x5061756c; 结果为Paul
select x'4d7953514c';结果为MySQL
select hex('cat');结果为636174
select TRUE,true, FALSE,false;结果为1,1,0,0
select * from 'select' where 'select'.id>100;
create table orders('my orders' varchar(100));
删除表:drop table student;
show databases;
use 数据库名;
desc user;
describle 表名;或 desc 表名;
'#', '--'均可用于注释
create database school;
drop database school;
drop database if exists school;
create table student #建立学生表
(
id int(5) auto_increment not null primary key,
name char(10) not null,
address varchar(50) default '清华大学'
year date
);
select left(address,10) from student; 只看address的前10个字符
select count(*) from student;统计记录数
select (100+98+99)/3;当计算器来用
select """hello";结果为"hello, 将2个双引号当做1个双引号
或select "\"hello";结果为"hello
select '''hello';结果为'hello
select '\'hello';结果为'hello
select 0xa+0; 结果为10
select 0x5061756c; 结果为Paul
select x'4d7953514c';结果为MySQL
select hex('cat');结果为636174
select TRUE,true, FALSE,false;结果为1,1,0,0
select * from 'select' where 'select'.id>100;
create table orders('my orders' varchar(100));
删除表:drop table student;
本文转自 tianya23 51CTO博客,原文链接:http://blog.51cto.com/tianya23/258755,如需转载请自行联系原作者