码迷,mamicode.com
首页 > 数据库 > 详细

mysql二进制安装

时间:2017-08-23 22:58:19      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:mysql

1、添加用户

useradd  mysql -s  /sbin/nologin -M

2、下载解压软件

rz -y

tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz

mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32

ln -s /application/mysql-5.5.32/ /application/mysql/

3、初始化数据库

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

4、授权MySQL管理数据库文件

chown -R mysql.mysql /application/mysql/

5、生成MySQL配置文件

cp /application/mysql/support-files/my-small.cnf /etc/my.cnf


6、配置启动MySQL

sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe

/application/mysql/bin/mysqld_safe &  后台开启mysqld服务进程

lsof -i :3306  进程已开启


7、配置环境变量

 echo $PATH

 cp /application/mysql/bin/* /usr/local/sbin/

 which mysql


8、配置传统方式启动mysqld服务

cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld

sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

killall mysqld

lsof -i :3306  发现进程已关闭

/etc/init.d/mysqld start

lsof -i :3306  发现进程已开启

chkconfig mysqld on  设置开机自启动

chkconfig --list mysqld  查看开机自启动




安全优化

1、设置mysql密码

mysqladmin -uroot password "123456"

mysql -uroot -p123456  用密码登录mysql

mysql -uroot -p  进入交互式密码登录

更改密码

mysqladmin -uroot -p123456 password "wuyike"

2、安全优化

删除test数据库

drop database test;

删除无用用户

select user,host from mysql.user;

drop user ‘用户‘@‘主机名‘   用户大写,特殊字符删不了,用delete(delete from mysql.user where user="root"and host="A";)

drop user ‘root‘@‘wuyike‘;

drop user ‘root‘@‘::1‘;

drop user ‘‘@‘wuyike‘;

剩下如下用户:

mysql> select user,host from mysql.user;

+------+-----------+

| user | host      |

+------+-----------+

| root | 127.0.0.1 |

| root | localhost |

+------+-----------+

如果误删:

grant all on *.* to ‘root‘@localhost identified by ‘123456‘with grant option;flush privileges;



3、简单命令

帮助:help drop;

查库:show databases;================>ls

切库:use mysql或别的库名; ==========>cd

查表:show tales;

查看用户列表:select user,host from mysql.user;

查看当前用户:select user();=========>whoami

查看当前所在库:select database(); =======>pwd

删除数据库:drop database 库名;

删除用户:drop user ‘用户‘@‘主机‘;


http://blog.csdn.net/wh211212/article/details/52856240


mysql二进制安装

标签:mysql

原文地址:http://11815879.blog.51cto.com/11805879/1958764

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!