一)mysql “安装” “绿色版”mysql 已经编译好,不需要编译,只需要mv到相应目录。 step)1 执行mysql 初始化命令, 命令太长 \ 换行, \后面不能有空格!! /usr/local/mysql/bin/mysqld --initialize --user=mysql \ --basedir=/usr/local/mysql --datadir=/data/mysql 如果上面命令报错。有libaio相关字样报错。则是需要安装相关依赖包 yum -y install libaio rpm -qa |grep libaio rm -rf /data/mysq/* ###需要清理一下目录,确保他是空目录。 step)2 记录密码。初始化给的一个随机密码。只显示一次。后面第一次登陆后,需要修改密码 generated for root@localhost: mxox?ppZj2rf step)3 546 cp my.cnf /etc/ 547 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 548 vi /etc/init.d/mysql 549 chmod 755 /etc/init.d/mysql 550 ln -s /usr/local/mysql/bin/mysql /usr/local/bin 551 chkconfig --add mysql 552 chkconfig --level 2345 mysql on 555 systemctl daemon-reload 556 systemctl start mysql 557 systemctl status mysql 558 netstat -tunlp |grep -i listen | grep 3306 559 history | tail step) 4 登陆mysql mysql -u root -p 回车 mysql -u root -p'mxox?ppZj2rf' mysql -u root -p abc set password=password('123.com'); 二)sql语句 structure query language 分类 DDL create,drop DML insert,update,delete DQL select DCL grant,revoke mysql> create table users( user_name char(16) not null, user_passwd char(48) default '', primary key (user_name)); #授权 mysql> select user,host from user; +---------------+-----------+ | user | host | +---------------+-----------+ | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +---------------+-----------+ 3 rows in set (0.00 sec) GRANT ALL ON db1.* TO 'jeffrey'@'localhost'; GRANT ALL ON *.* TO 'qingmei'@'%'; REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ... REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'qingmei'@'%'