Centos manually install mysql8

download##

The official website is too slow, download it from the Tsinghua mirror station: https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/

Binary version##

The binary version is the official pre-compiled version

Download the binary release package###

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

Create user###

useradd mysql

initialization###

table of Contents:

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

database:

mysqld --initialize --user=mysql

Check configuration###

vi /etc/my.cnf

Check whether the datadir configured in /etc/my.cnf is the same as that during initialization.

[ mysqld]
datadir=/var/lib/mysql

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

The default datadir must be changed to the init directory.

The default client is /var/lib/mysql.sock, so you can only log in as follows:

mysql -uroot -p --socket=/var/lib/mysql/mysql.sock

Therefore, the default client access must be modified to use a custom sock before the application can access.

Configuration service###

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

If an error is reported, check whether the datadir configured in /etc/my.cnf is the same as that during initialization.

Initialize the data table and permissions###

mysql_secure_installation

Compile and install##

If it is not necessary, do not consider the way of compiling and installing, because compiling is very slow, and once a dependency conflict is encountered, it is very troublesome to resolve.

What is necessary?

Have you figured it out? Then it starts. . . . (Prepare for 3 hours)

Installation dependencies###

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

Download source package###

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

Compile###

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

# The following process is very slow
make && make install

The subsequent steps are similar to binary, but there are some problems in some links.

Create user###

useradd mysql

initialization###

table of Contents:

chown -R mysql:mysql /usr/local/mysql

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

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

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

database:

mysqld --initialize --user=mysql

I encountered a problem here:

This problem was not encountered in the binary version. After analysis, modify the configuration file according to the following official website configuration:

[ mysqld]
character_set_server=latin1
collation_server=latin1_swedish_ci

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-1.html

Just re-initialize.

After testing, it can be modified as follows:

character-set-server = utf8
collation-server = utf8_general_ci

This is closer to the actual situation, but why does this so-called mysql8 new feature character set "utf8mb4_0900_ai_ci" report an error?

It is speculated that the character set corresponding to utf8mb4_0900_ai_ci is not utf8, but utf8mb4, so the initial compilation with -DDEFAULT_CHARSET=utf8 parameter is in conflict with mysql8 default using utf8mb4_0900_ai_ci as the collation character set.

Therefore, either modify the default character set to utf8mb4 to make it adaptive:

- DDEFAULT_CHARSET=utf8mb4 \

Either completely configure these two character sets to match the associated character sets:

- DDEFAULT_CHARSET=utf8 \
- DDEFAULT_COLLATION=utf8_general_ci \

Configuration service###

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

Initialize the data table and permissions###

mysql_secure_installation

What should I do if the compilation fails?

First find the reason, or clue, install the required dependencies, or modify the required environment.

Clean up the scene:

make clean
rm -f CMakeCache.txt

Started again.

Permissions issue##

The permission management method of mysql 8 has changed. The previous method may not be very useful.

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';

Easter eggs##

If you just want to see what the hell is mysql8, you can start it with docker:

docker run -de MYSQL_ROOT_PASSWORD=123456-p 3306:3306--name mysql mysql:8.0.11

test:

docker exec -ti mysql mysql -uroot -p

The password is 123456, a few minutes later, the brick is thrown over.

Recommended Posts

Centos manually install mysql8
CentOS7.2 install Mysql5.7.13
CentOS install mysql
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Install mysql under Centos 7
Centos7 install Mysql database
Install mysql5.1 under CentOS6.5
Install mysql online on centos
centos install mysql through yum
Install MySQL 8.0.16 on Linux Centos
Install MySQL under Linux (CentOS 7)
Centos6 install mysql 5.7.x series
1.5 Install Centos7
CENTOS7 manually install CEPH original
CentOS8 install MySQL8 (pro test)
How to install MySQL on CentOS 8
CentOS7 yum install and start mysql
CentOS 7 install Nginx, PHP, MySQL packages
Install MySql with Docker in CentOS7
Install MySQL on Linux CentOS7 (Windows)
CentOS7 yum install and start mysql
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Centos yum install mysql5.6 or above
centos7 .*tar package to install MySQL5.7
Centos6 install Python2.7.13
CentOS install Redmine
Centos7 install Python 3.6.
CentOS 7 install Docker
CentOS7 install GlusterFS
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
Centos7 install Python2.7
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS6 install mist.io
Centos7 install Docker
centOs install rabbitMQ
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp