mysql 基本命令
1、登陆MySQL:
mysql -u root -p
2、查看用户信息
select user,host,password from mysql.user;
select user,host from mysql.user;
3、设置密码
set password for root@localhost=password('
在这里填入root密码
');
4、修改密码
方法1:mysqladmin -u root -p password newpassword
方法2: #mysql -u root -p mysql
mysql>UPDATE user SET password=PASSWORD("new") WHERE user='root';
mysql>flush privileges;
5
、删除匿名用户
delete from mysql.user where user='';
6
、查看系统已存在的数据库
show databases;
7、删除名为test的空数据库
drop database test;
8、建立mysql用户
例a:
建立对test数据库有完全操作权限的名为centospub的用户
mysql>grant all privileges on test.* to centospub@localhost identified by 'password';
例b:
增加一个用户test1密码为abc,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MYSQL,然后键入以下命令:
mysql>grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
但例b增加的用户是十分危险的,你想如某个人知道test1的密码,那么他就可以在internet上的任何一台电脑上登录你的mysql数据库并对你的数据可以为所欲为了。
例c:
增加一个用户test2密码为abc,让他只可以在localhost上登录,并可以对数据库mydb进行查询、插入、修改、删除的操作
(localhost指本地主机,即MYSQL数据库所在的那台主机),这样用户即使用知道test2的密码,他也无法从internet上直接访问数据
库,只能通过MYSQL主机上的web页来访问了。
mysql>grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
9、查找
确认centospub用户的存在与否
select user from mysql.user where user='centospub';
10、
建立名为test的数据库
create database test;
11
、取消centospub用户对数据库的操作权限
revoke all privileges on *.* from centospub@localhost;
12
、删除centospub用户
delete from mysql.us
相关文档:
Error Code : 1418
This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
(0 ms taken)
分析:
根据系统提示,导致该错误的原因可能是一个安全设置方面 ......
对mysql存储过程的简单应用
向表中插入模拟数据,检查分页效果是否出错。
create procedure dowhile()
begin
declare cnt INT default 0;
while cnt<100 do
INSERT INTO `test`.`news` (`F_ID` ,`F_TITLE` ,`F_CLASSID` ,`F_ISUP` ,`F_CONTENT` ,`F_SOURCE` ,`F_DATETIME` ,`F_RE ......
参见官方参考,第25章:API和库
25.2.3.49. mysql_ping()
int
mysql_ping(MYSQL *mysql)
描述
检查与服务器的连接是否工作。如果连接丢失,将自动尝试再连接。
该函数可被闲置了较长时间的客户端使用,用以检查服务器是否已关闭了连接,并在必要时再次连接。
返回值
如果与服务器的连接有效返回 ......
一、MYSQL存储引擎大全:
·MyISAM:默认的MySQL插件式存储引擎,它是在Web、数据仓储和其他应用环境下最常使用的存储引擎之一。注意,通过更改STORAGE_ENGINE配置变量,能够方便地更改MySQL服务器的默认存储引擎。
·InnoDB:用于事务处理应用程序,具有众多特性,包括ACID事务支持。
·BDB:可替代I ......