mysql二进制安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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二进制安装的主要内容,如果未能解决你的问题,请参考以下文章

centos7 二进制安装包安装 mysql5.6

二进制包安装MYSQL

MySQL安装(yum二进制源码)

MySQL 安装(二进制版)

mysql-5.5.56版本(二进制包安装)-自定义安装路径

mysql-5.7.18版本(二进制包安装)-自定义安装路径