| 我的简单安装及初级使用。(摘录一些初级应用,基础很重要的)以备以后查看。 参考安装文档: shell> groupadd mysql shell> useradd -g mysql mysql shell> cd /usr/local shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf - shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql shell> cd mysql shell> scripts/mysql_install_db --user=mysql shell> chown -R root . shell> chown -R mysql data shell> chgrp -R mysql . shell> bin/mysqld_safe --user=mysql & 启动mysql; 一、连接MYSQL。格式: mysql -h主机地址 -u用户名 -p用户密码 二、修改密码。格式:mysqladmin -u用户名 -p旧密码 password 新密码 三、增加新用户。(注意:和上面不同,下面的因为是MYSQL环境中的命令,所以后面都带一个分号作为命令结束符) 格式: grant select on 数据库.* to 用户名@登录主机 identified by "密码" grant select,insert,update,delete on *.* to test1@"%" Identified by "abc"; grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
如果你不想test2有密码,可以再打一个命令将密码消掉。 grant select,insert,update,delete on mydb.* to test2@localhost identified by ""; [root@proxy bin]# ./mysql -uroot -pmysql
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL
connection id is 23 to server version: 4.0.24-standard Type 'help;' or '\h' for help.
Type '\c' to clear the buffer.
mysql> 1、显示数据库列表。 show databases; 刚开始时才两个数据库:mysql和test。mysql库很重要它里面有MYSQL的系统信息,我们改密码和新增用户,实际上就是用这个库进行操作。 2、显示库中的数据表: show tables; 3、显示数据表的结构: describe 表名; 4、建库: create database 库名; 5、建表: 库名; create table 表名 (字段设定列表); 6、删库和删表: drop database 库名; drop table 表名; 7、将表中记录清空: delete from 表名; 8、显示表中的记录: select * from 表名; |