MySQL 远程连接
问题:远程连接服务器的数据库
$ mysql -hserverip -uuser -ppassword
ERROR 1045 (28000): Access denied for user 'user'@'localhost'
(using password: YES)
原因:mysql.user表中没有设置远程连接
$ mysql -uroot -ppassword #用root用户在server上登录
mysql> select host, user, password from mysql.user; #查看mysql数据库user表中的信息
会发现没有远程机器的host, 当然也没有user
解决方法:
mysql> grant select, update, insert, delete on *.* to user@clientip identified by "password";
这样在远程客户端clientip就可以访问数据库了
$ mysql -hserverip -uuser -ppassword
附加:
如果想让所有的远程机器都可以用user用户访问数据库可以在服务器数据库中做如下设置
mysql> grant all on *.* to user@"%" identified by "password";
相关文档:
START TRANSACTION, COMMIT和ROLLBACK语法
START TRANSACTION | BEGIN [WORK]
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
SET AUTOCOMMIT = {0 | 1}
START
TRANSACTION或BEGIN语句可以开始一项新的事务。COMMIT可以提交当前事务,是变更成为永久变更。ROLLBACK ......
所有的数学函数在一个出错的情况下返回NULL。
-
单目减。改变参数的符号。
mysql> select - 2;
注意,如果这个操作符与一个BIGINT使用,返回值是一个BIGINT!这意味着你应该避免在整数上使用-,那可能有值-2^63!
ABS(X)
返回X的绝对值。
mysql> select ABS(2);&n ......
TINYINT 1 字节
SMALLINT 2 个字节
MEDIUMINT 3 个字节
INT 4 个字节
INTEGER 4 个字节
BIGINT 8 个字节
FLOAT(X) 4 如果 X < = 24 或 8 如果 25 < = X < = 53
FLOAT 4 个字节
DOUBLE 8 个字节
DOUBLE PRECISION 8 个字节
REAL 8 个字节
DECIMAL(M,D) M字节(D+2 , 如果M < D)
NUMERIC(M,D) M字节(D ......
drop table student;
create table student
(sno int not null unique,
sname varchar(8) not null,
ssex char(2) not null,
sage int ,
sdept varchar(20));
select * from student;
alter table student drop uniq ......