The official website is too slow, download it from the Tsinghua mirror station: https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/
The binary version is the official pre-compiled version
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.11-el7-x86_64.tar.gz
useradd mysql
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
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.
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.
mysql_secure_installation
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)
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
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.11.tar.gz
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.
useradd mysql
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
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.
-DDEFAULT_CHARSET=utf8
, which is the culprit.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 \
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
mysql_secure_installation
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.
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';
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