李子

mysql8.0离线安装和配置
项目需求,领导要上8.0特性:默认开启事件调整了部分默认参数值新增部分动态配置项支持在线修改全局参数持久化查询缓功...
扫描右侧二维码阅读全文
18
2018/09

mysql8.0离线安装和配置

项目需求,领导要上8.0

特性:
默认开启事件
调整了部分默认参数值
新增部分动态配置项
支持在线修改全局参数持久化
查询缓功能影响性能在8.0已经被剔除
innodb_buffer_pool_size内存参数自适应,运维无需对服务器内存进行分配。

卸载旧包:
rpm -e --nodeps mysql-community-libs-5.7.19-1.el6.x86_64
rpm -e --nodeps mysql-community-server-5.7.19-1.el6.x86_64
rpm -e --nodeps mysql-community-common-5.7.19-1.el6.x86_64
rpm -e --nodeps mysql-community-libs-compat-5.7.19-1.el6.x86_64
rpm -e --nodeps mysql-community-client-5.7.19-1.el6.x86_64
rpm -e --nodeps mysql-community-devel-5.7.19-1.el6.x86_64

安装依赖:
yum install cmake
yum install ncurses-devel
yum install bison
yum install git openssl-devel
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison git openssl-devel

使用二进制包直接部署:
tar xf mysql-8.0.12-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql
groupadd mysql
useradd -d /usr/local/mysql -g mysql -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
mkdir /var/lib/mysql
chown mysql:mysql /var/lib/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/lib/mysql /usr/lib64/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe
或者
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile

mkdir -p /data/mysql/data
chown -R mysql:mysql /data/mysql/

配置为空密码,方便后续直接修改:
/usr/local/mysql/bin/mysqld --user=mysql --datadir=/data/mysql/data --initialize-insecure

chkconfig --level 35 mysqld on
/etc/init.d/mysqld restart

修改密码策略/创建用户并授权:
mysql -uroot -e "alter user root@'localhost' identified by 'password' password expire never;"
mysql -uroot -ppassword -e "flush privileges;"
mysql -uroot -ppassword -e "alter user root@'localhost' identified with mysql_native_password by 'password';"
mysql -uroot -ppassword -e "create user root@'127.0.0.1' identified with mysql_native_password by 'password';"
mysql -uroot -ppassword -e "grant all privileges on . to root@'127.0.0.1' with grant option;"
mysql -uroot -ppassword -e "flush privileges;"

Last modification:September 18th, 2018 at 10:49 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment