mysql二进制安装的优缺点_Mysql二进制安装

Mysql二进制安装

mysql5.7,8.0 通用二进制安装

mysql安装前准备

#CentOS 8 安装5.7,8.0版本需要安装以下包

dnf -y install libaio ncurses-compat-libs

#CentOS 7 安装5.7,8.0不需要额外安装其他包

#CentOS 6 安装5.7,8.0版本需要安装以下包

yum -y install libaio numactl

#CentOS 8 如果没有libaio和ncurses-compat-libs包,会提示以下错误,其他版本错误类似

[root@centos82 local]#mysqld --initialize --user=mysql --datadir=/data/mysql

mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

[root@centos82 local]#mysql -uroot -p744123

mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

安装操作步骤

#将压缩包解压到指定目录

tar xvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

tar xvf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz -C /usr/local/

#进入解压缩目录

cd /usr/local

#建立软连接并更改权限

ln -s mysql-5.7.30-linux-glibc2.12-x86_64/ mysql

ln -s mysql-8.0.20-linux-glibc2.12-x86_64/ mysql

chown -R root.root /usr/local/mysql/

#mysql用户组和用户的创建

groupadd -r -g 306 mysql

useradd -r -u 306 -g306 -s /bin/false mysql

#环境变量设置

##方法1:

echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh

. /etc/profile.d/mysql.sh

##方法2:

ln -s /usr/local/mysql/bin/* /usr/local/bin/

#准备配置文件

vim /etc/my.cnf

[mysqld]

datadir=/data/mysql

skip_name_resolve=1

socket=/data/mysql/mysql.sock

log-error=/data/mysql/mysql.log

pid-file=/data/mysql/mysql.pid

[client]

socket=/data/mysql/mysql.sock

[mysql]

auto-rehash

prompt="\\u@\\h [\\d]>"

#初始化数据库

mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql

#准备服务脚本

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

#启动mysql

chkconfig --add mysqld

service mysqld start

#提取root初始化密码

awk '/temporary password/{print $NF}' /data/mysql/mysql.log

#修改root登录口令

mysqladmin -uroot -p'Gzd4nvcg!&/+' password 744123

#登录mysql

mysql -uroot -p744123

你可能感兴趣的:(mysql二进制安装的优缺点)