centos7安装mysql8

2018-04-27

mysql8据说比5.7快两倍,官方推荐用2进制方式安装。

 

从MySQL 5.7.5开始Boost库是必需的,Mysql5.7版本更新后有很多变化,比如json等,连安装都有变化,他安装必须要BOOST库

 

1、下载

https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.11-el7-x86_64.tar.gz二进制

https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.11.tar.gz源码

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

2、useradd mysql

3、tar xvfz mysql-8.0.11-el7-x86_64.tar.gz
cd mysql-8.0.11-el7-x86_64

ln -s $PWD /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql

export PATH=$PATH:/usr/local/mysql/bin

mkdir -p /var/log/mariadb
chown -R mysql:mysql /var/log/mariadb

mkdir -p /var/run/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/run/mariadb

4、初始化数据库

mysqld --initialize --user=mysql默认临时密码在错误日志里或检查返回信息

mysqld --initialize-insecure --user=mysql无密码

5、vi /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
[client]
socket=/var/lib/mysql/mysql.sock

6、默认是socket方式,因此只能如下方式登录:mysql -uroot -p --socket=/var/lib/mysql/mysql.sock

7、cp support-files/mysql.server /etc/init.d/mysqld chmod a+x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start

8、初始化数据表及权限

mysql_secure_installation

###源码安装############################################
1、安装编译器
yum install libaio -y
yum install glibc-devel.i686 glibc-devel -y
yum install gcc gcc-c++ cmake boost-devel openssl-devel ncurses-devel -y

2、tar xvfz mysql-8.0.11.tar.gz
cd mysql-8.0.11

cmake . \
-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/include/boost \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/mysql_data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all

make && make install

3、mysql8的权限管理方式改变
mysql> create role app_read;
Query OK, 0 rows affected (0.03 sec)

mysql> grant all on *.* to app_read;
Query OK, 0 rows affected (0.07 sec)

mysql> create user root@'%' identified by 'dCa0tyVgN1&o';

 

分类:Linux数据库 | 标签: |

相关日志

评论被关闭!