欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

CentOS7.4编译安装MySQL5.7.21的详细教程

程序员文章站 2022-06-23 14:42:10
一、卸载mariadb centos7默认安装了和mysql有兼容性的mariadb,在我们安装mysql5.7之前为了避免发生冲突首先删除mariadb。 # rpm -qa | grep mar...

一、卸载mariadb

centos7默认安装了和mysql有兼容性的mariadb,在我们安装mysql5.7之前为了避免发生冲突首先删除mariadb。

# rpm -qa | grep maria

yum remove mariadb-libs -y

二、安装环境

yum -y install make cmake bison-devel ncurses-devel gcc gcc-c++ kernel-devel &&\

yum install -y readline-devel pcre-devel openssl-devel openssl zlib zlib-devel pcre-devel perl perl-devel wget

三、下载boost,一定要是1_59_0

wget -c https://dl.bintray.com/boostorg/release/1.59.0/source/boost_1_59_0.tar.gz

tar -xzvf boost_1_59_0.tar.gz

cp boost_1_59_0 /usr/local/

四、安装mysql

wget -c https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.22.tar.gz &&\

tar -zxvf mysql-5.7.22.tar.gz && rm -f mysql-5.7.22.tar.gz && cd mysql-5.7.22

cmake . -dcmake_install_prefix=/usr/local/mysql -dmysql_datadir=/var/lib/mysql -dsysconfdir=/etc -dwith_innobase_storage_engine=1 -dwith_archive_storage_engine=1 -dwith_blackhole_storage_engine=1 -dwith_federated_storage_engine=1 -dwith_partition_storage_engine=1 -dmysql_unix_addr=/tmp/mysqld.sock -denabled_local_infile=1 -dwith_extra_charsets=all -dmysql_user=mysql -ddownload_boost=1 -dwith_boost=/usr/local/boost_1_59_0

gmake && make install

五、安装之后的一些配置:

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

mkdir /var/lib/mysql

chown mysql. mysql

vi /etc/my.cnf

[mysqld]

basedir = /usr/local/mysql

datadir = /var/lib/mysql

port = 3306

socket = /tmp/mysqld.sock

mysql_install_db 被废弃了,取而代之的是 mysqld –initialize

# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize --datadir=/var/lib/mysql --basedir=/usr/local/mysql --user=mysql

# systemctl start mysql

# ps -ef|grep mysql

# vi ~/.bash_profile

path=$path:$home/bin:/usr/local/mysql/bin

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

# mysql

error 1045 (28000): access denied for user 'root'@'localhost' (using password: no)

配置文件中添加如下一行,跳过密码验证

# cat /etc/my.cnf

[mysqld]

skip-grant_tables

重启mysql

# systemctl restart mysql

# mysql

mysql> update mysql.user set authentication_string=password('oracle') where user='root' ;

再次重启mysql

# systemctl restart mysql

# mysql

mysql> show databases;