centos7下安装mysql5.7

1.安装mysql依赖

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

2.下载mysql安装包

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.17.tar.gz  
tar -zxvf mysql-5.7.17.tar.gz   
cd mysql-5.7.17  

3.增加mysql用户和用户组

groupadd mysql   
useradd -g mysql mysql 

4.创建数据目录


chown mysql.mysql -R /usr/local/mysql/   
mkdir -p /var/mysql/  
mkdir -p /var/mysql/data/  
chown mysql.mysql -R /var/mysql/

5.编译安装

cd /usr/local
/*mysql DDOWNLOAD_BOOST 会自动安装在这个目录上*/
mkdir boost_1_59_0
cmake \
     -DMYSQL_DATADIR=/var/mysql/data \
     -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
     -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
     -DDEFAULT_CHARSET=utf8 \
     -DWITH_EXTRA_CHARSETS:STRING=all \
     -DDEFAULT_COLLATION=utf8_general_ci \
     -DWITH_INNOBASE_STORAGE_engine=1 \
     -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
     -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
     -DMYSQL_TCP_PORT=3306 \
     -DENABLE_DOWNLOADS=1 \
     -DDOWNLOAD_BOOST=1 \
     -DWITH_BOOST=/usr/local/boost_1_59_0 \
     -DMYSQL_USER=mysql
/*编译时间会比较漫长*/
make
make install

6.配置mysql文件

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf


# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /var/mysql/data
port = 3306
server_id = 1
socket = /var/mysql/mysql.socket

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket=/var/mysql/mysql.socket

7.增加mysql环境变量

vi /etc/profile
/*尾部增加*/
PATH=$PATH:/usr/local/mysql/bin
export PATH

/*保存成功后*/
source /etc/profile

8.初始化mysql数据

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

9.启动mysql

/etc/init.d/mysqld start
没有报错的话 恭喜你安装成功了

10.进mysql修改密码

/*使用该命令 再敲mysql 可以直接进mysql*/
mysqld_safe --skip-grant-tables &
mysql
use mysql
update user set authentication_string=password('123abc') where user='root';
/*然后退出安全模式重新登录*/
mysql -uroot -p
123abc
/*这时候不管你怎么操作都会提示*/
You must reset your password using ALTER USER statement before executing this statement.
/*再设置一次密码*/
alter user 'root'@'localhost' identified by 'asdasd;657567';

11.增加远程mysql用户

Grant all on *.* to 'root'@'%' identified by 'user123' with grant option;
flush privileges;

mysql5.7你就安装完啦 啊哈哈哈哈哈哈哈哈啊

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值