2.2.2mysql部署

mysql官网上下载自己适合的mysql版本

https://dev.mysql.com/downloads/mysql/5.6.html#download

上传到本地,解压,移动

[root@localhost ~]# tar xf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz

[root@localhost ~]# mv mysql-5.6.37-linux-glibc2.12-x86_64 /usr/local/mysql-5.6

[root@localhost ~]# cd /usr/local/mysql-5.6/

[root@localhost mysql-5.6]#

再创建用户和用户组,赋予权限

[root@localhost local]# groupadd mysql

[root@localhost local]# useradd -r -g mysql mysql

[root@localhost local]# chown -R mysql.mysql /usr/local/mysql-5.6/

初始化数据库,bin下或者scripts下找到mysql_install_db

[root@localhost scripts]# ls

mysql_install_db

[root@localhost scripts]# /usr/local/mysql-5.6/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.6/ --datadir=/usr/local/mysql-5.6/data

-bash: /usr/local/mysql-5.6/scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory

报错原因:缺 perl perl-devel包。

解决办法:安装上即可:

yum install -y perl perl-devel

[root@localhost scripts]# /usr/local/mysql-5.6/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.6/ --datadir=/usr/local/mysql-5.6/data

FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql-5.6/scripts/mysql_install_db:Data::Dumper

再次报错,解决方法 :安装autoconf

命令:

yum -y install autoconf libaio

再次执行初始化操作,则正常进行。

 

 

 

完成初始化后编辑配置文件 /etc/my.cnf

 [root@localhost support-files]# cd /usr/local/mysql-5.6/support-files

 [root@localhost support-files]# cp my-default.cnf  /etc/my.cnf

cp: overwrite ‘/etc/my.cnf’? y

[root@localhost support-files]# vi /etc/my.cnf

 修改如下配置:

basedir = /usr/local/mysql-5.6

 datadir = /usr/local/mysql-5.6/data

 port = 3306

 user=mysql

 socket = /tmp/mysql.sock

 character-set-server = utf8

 skip-name-resolve

#取消密码验证

# skip-grant-tables

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# skip-grant-tables

[mysqld_safe]

 log-err = /usr/local/mysql-5.6/data/error.log

 pid-file = /usr/local/mysql-5.6/data/mysql.pid

 

 

 

mysql加入到服务

[root@localhost scripts]# cp /usr/local/mysql-5.6/support-files/mysql.server /etc/init.d/mysql

开机启动

[root@localhost scripts]# chkconfig mysql on

启动mysql

[root@localhost scripts]# service mysql start

Starting MySQL.Logging to '/usr/local/mysql-5.6/data/localhost.localdomain.err'.

 SUCCESS!

配置环境变量

[root@localhost scripts]# vim /etc/profile

 

添加:

export PATH=$PATH:/usr/local/mysql-5.6/bin

 

[root@localhost scripts]# source /etc/profile

 [root@localhost scripts]# mysql

 

 

 

安装完成。