CentOS-mysql命令

piaoling  2013-08-30 18:50:49
安装mysql服务:yum -y install mysql-server
设置mysql服务随系统启动自启动:chkconfig mysqld on
确认mysql自启动:chkconfig --list mysqld 如果2-5为on的状态就OK
启动mysql服务:/etc/rc.d/init.d/mysqld start
关闭mysql服务:/etc/rc.d/init.d/mysqld stop
进入命令:mysql -u root -p
进入远程主机:mysql -u root -h 192.168.168.11
退出命令:exit
显示数据库:show databases;
删除数据库:drop databases 数据库名称
显示数据表:show tables;
删除数据表:drop table 数据表名称
查看用户信息:select user,host,password from mysql.user;
设置用户密码:set password for root@localhost=password('2191888');
删除用户:delete from mysql.user where user='centospub';
建立对test数据库有完全操作权限的名为centospub的用户:
grant all privileges on test.* to centospub@localhost identified by '2191888' 
连接到数据库:use test
插入一个值到表中:insert into test values(1,'Hello World!');
查询表中的信息:select * from test;
更新表的信息:update test set name='Hello Everyone'
删除表内的值:delete from test where num=1;
取消centospub用户对数据的操作权限:
revoke all privileges on *.* from centospub@localhost;
删除centospub用户:
delete from mysql.user where user='centospub' and host='localhost';
刷新:flush privileges;
类别 :  默认(739)  |  浏览(3910)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: