下载mysql 5.7 tar包
选择 mysql-5.7.11.tar.gz
tar zxvf mysql-5.7.11.tar.gz
cd mysql-5.7.11
在这里需要看下INSTALL-SOURCE 文件, 里面说了需要 cmake . -DWITH_BOOST=/usr/local/boost_1_59_0
首先要安装cmake, 然后是下载boost1.59.0 版本号必须严格一致
将boost解压在 /usr/local 目录即可,当热也可以在其他地方
mkdir build
cd build
cmake .. -DWITH_BOOST=/usr/local/boost_1_59_0
make ## 这个过程会比较长
make install 会安装在 /usr/local/mysql 目录
把mysql 加入PATH
export PATH=/usr/local/mysql/bin:$PATH
把 support-files/my-default.cnf 拷贝到 /etc/my.cnf 添加适当的配置,
比如:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# 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 = .....
# datadir = .....
# port = .....
# server_id = 1
# 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
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock # 如果mysqld里面设置了socket, 这里一定也要加上,不然就会连不上,客户端会尝试使用 /tmp/mysql.sock
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld ## 替换系统老的mysqld
安装mysql db, 老的命令是 mysql_install_db, 新版变为
mysqld --initialize
这个命令会创建很多数据库
会得到一个临时密码,比如 pI-Ke0PN%qq=
然后立即启动mysql
/etc/init.d/mysqld start ## 前提是把mysql/support-files/mysql.server 拷贝到 /etc/init.d/mysqld
理论上这里用 service mysqld start 也应该能成功,不过我没成功,
打开/var/log/mysqld.log 发现我编译mysql时用的是 /usr/local/bin/gcc 5.2版本的,而启动服务的时候默认是链接/usr/lib64下的c++库,导致找不到
加一句到 /etc/init.d/mysqld启动脚本里面
export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH
重新执行 service mysqld start 启动成功
然后立即用临时密码登录 mysql -uroot -p
进去后需要用 alter user 'root'@'localhost' identified by 'xxx'; 来重置root的密码
这时候才可以 用别的grant语句
grant all privileges on *.* to root@localhost identified by 'xxx';
grant all privileges on *.* to root@'%' identified by 'xxx';
阅读(1159) | 评论(0) | 转发(0) |