码迷,mamicode.com
首页 > 数据库 > 详细

Centos7.3中安装MySQL5.7

时间:2018-07-10 23:32:41      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:har   rfs   cat   root   port   运行   reload   ges   文件删除   

首先安装相关环境包

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

添加MySQL程序用户

useradd -s /sbin/nologin mysql

解压软件包

tar zxvf mysql-5.7.17.tar.gz -C /opt/
tar zxvf boost_1_59_0.tar.gz -C /usr/local/ 解压c++运行库
cd /usr/local/
mv boost_1_59_0 boost 重命名,方便管理

cd mysql-5.7.17/

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DSYSCONFDIR=/etc -DSYSTEMD_PID_DIR=/usr/local/mysql -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_BOOST=/usr/local/boost -DWITH_SYSTEMD=1
  • 注意:如果在CMAKE的过程中有报错,当报错解决后,需要把源码目录中的CMakeCache.txt文件删除,然后再重新CMAKE,否则错误依旧。

make && make install

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

vi /etc/my.cnf

[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

更改MySQL用户属主属组

chown mysql:mysql /etc/my.cnf

添加环境变量

echo ‘PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH‘ >> /etc/profile
echo ‘export PATH‘ >> /etc/profile
source /etc/profile

cd /usr/local/mysql/

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

复制服务启动脚本

cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld
netstat -anpt | grep 3306

systemctl enable mysqld 设置开机自启动

设置mysql登录用户账户

mysqladmin -u root -p password "abc123" //给root账号设置密码为abc123提示输入的是原始密码。

mysql -u root -p

授权远程登录

grant all privileges on . to ‘root‘@‘%‘ identified by ‘abc123‘ with grant option;

Centos7.3中安装MySQL5.7

标签:har   rfs   cat   root   port   运行   reload   ges   文件删除   

原文地址:http://blog.51cto.com/13659253/2140068

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!