操作系统:CentOS 7.6 64位

MySQL版本:5.6.14

安装

安装编译环境

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

下载MySQL源码

wget https://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.14.tar.gz

解压源码

tar -zxvf mysql-5.6.14.tar.gz    

进入解压目录,准备编译安装

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc-DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306-DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENHINE=1-DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci

编译安装

make && make install

配置

创建MySQL用户和组

groupadd mysql

useradd -g mysql mysql

修改目录权限

chown -R mysql:mysql /usr/local/mysql

初始化配置

进入mysql目录

cd /usr/local/mysql

我这里报错提示少了组件,安装perl插件

yum install 'perl(Data::Dumper)'

执行初始化指令

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

修改名称,防止干扰

mv /etc/my.cnf /etc/my.cnf.bak

启动MySQL

进入/usr/local/mysql执行

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

设置自启动

chkconfig mysql on

启动MySQL

systemctl restart mysql

修改root密码

进入目录

cd /usr/local/mysql/bin

进入数据库

./mysql -u root -p   或者   ./mysql -u root

修改密码

SET PASSWORD = PASSWORD('root');