Install mysql8.0.13 version under Linux CentOS7 system

Foreword

I recently sorted out some steps and problems encountered in installing mysql8.0.13 under Linux CentOS7 system, and share with you!

One

Installation and error handling

  1. Go to the https://www.mysql.com/downloads/msyql download page and select the community version

  2. Check the linux version, select the corresponding version to download

  1. Copy the downloaded file mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz to a directory on the linux server, unzip it, and copy it to the usr/local directory, and rename it to mysql
[ root@VM_0_14_centos mysql]# tar -xvf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz
[ root@VM_0_14_centos mysql]# cp -rv mysql-8.0.13-linux-glibc2.12-x86_64 /usr/local
[ root@VM_0_14_centos mysql]# cd /usr/local 
[ root@VM_0_14_centos local]# mv mysql-8.0.13-linux-glibc2.12-x86_64 mysql
  1. Add mysql user
useradd -s /sbin/nologin -M mysql
  1. msyql initialization
/usr/local/mysql/bin/mysqld --initialize --user=mysql

A temporary password will be generated at this time

[ root@VM_0_14_centos mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql
2019- 01- 20 T10:56:07.718326Z 0[System][MY-013169][Server]/usr/local/mysql/bin/mysqld(mysqld 8.0.13) initializing of server in progress as process 58262019-01-20T10:56:16.915217Z 5[Note][MY-010454][Server] A temporary password is generated for root@localhost: twi=Tlsi<0O!2019-01-20T10:56:20.410563Z 0[System][MY-013170][Server]/usr/local/mysql/bin/mysqld(mysqld 8.0.13) initializing of server has completed
  1. Copy startup and shutdown scripts
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
  1. Modify the configuration file, save and exit wq
vim /etc/my.cnf
[ mysqld]
 basedir =/usr/local/mysql   
 datadir =/var/lib/mysql
 socket =/var/lib/mysql/mysql.sock
 character-set-server=utf8
 [ client]
 socket =/var/lib/mysql/mysql.sock
 default-character-set=utf8
  1. Start the database service
service mysqld start

Report an error

mysqld_safe Directory '/var/lib/mysql'for UNIX socket file don't exists.

One is because there is no /var/lib/mysql directory, and the other is because there is no write permission, the mysql.sock file cannot be generated.

[ root@VM_0_14_centos lib]# mkdir mysql
[ root@VM_0_14_centos lib]# chmod 777/var/lib/mysql

Run service mysqld start again and report another error

Starting MySQL. ERROR! The server quit without updating PID file(/var/lib/mysql/VM_0_14_centos.pid).

Print out the specific error message

[ root@VM_0_14_centos mysql]# cat VM_0_14_centos.err
2019- 01- 20 T11:11:45.906800Z 0[System][MY-010116][Server]/usr/local/mysql/bin/mysqld(mysqld 8.0.13) starting as process 77882019-01-20T11:11:45.910813Z 0[Warning][MY-013242][Server]--character-set-server:'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.2019-01-20T11:11:45.925456Z 1[ERROR][MY-011011][Server] Failed to find valid data directory.2019-01-20T11:11:45.925586Z 0[ERROR][MY-010020][Server] Data Dictionary initialization failed.2019-01-20T11:11:45.925600Z 0[ERROR][MY-010119][Server] Aborting
2019- 01- 20 T11:11:45.926342Z 0[System][MY-010910][Server]/usr/local/mysql/bin/mysqld: Shutdown complete(mysqld 8.0.13)  MySQL Community Server - GPL.2019-01-20T11:12:00.049920Z 0[System][MY-010116][Server]/usr/local/mysql/bin/mysqld(mysqld 8.0.13) starting as process 79752019-01-20T11:12:00.052469Z 0[Warning][MY-013242][Server]--character-set-server:'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.2019-01-20T11:12:00.060600Z 1[ERROR][MY-011011][Server] Failed to find valid data directory.2019-01-20T11:12:00.060745Z 0[ERROR][MY-010020][Server] Data Dictionary initialization failed.2019-01-20T11:12:00.060759Z 0[ERROR][MY-010119][Server] Aborting
2019- 01- 20 T11:12:00.061610Z 0[System][MY-010910][Server]/usr/local/mysql/bin/mysqld: Shutdown complete(mysqld 8.0.13)  MySQL Community Server - GPL.

Can't see the specific problem, so run service --status-all, there is an error message

ERROR! MySQL is not running, but lock file(/var/lock/subsys/mysql) exists

Some netizens said that it was enough to delete the file, but it was useless if I deleted it.

Then check the err file just now, the key error should be these two lines

2019- 01- 20 T11:11:45.925456Z 1[ERROR][MY-011011][Server] Failed to find valid data directory.2019-01-20T11:11:45.925586Z 0[ERROR][MY-010020][Server] Data Dictionary initialization failed.

So I searched for my.cnf. The configuration related to the data directory is datadir=/var/lib/mysql. I tried to delete this line. The result was successful, and the service mysqld start was successful!

  1. mysql -u root -p log in mysql error report

The solution is as follows:

cd /usr/local/bin  
ln -fs /usr/local/mysql/bin/mysql mysql
  1. show databases error
you must reset your password using ALTER USER statement before executing this statement.

Solution:

alter user user() identified by '123456';
  1. Cannot log in to mysql remotely with ip, but can only log in with localhost in linux server

Modify permissions configuration

grant all privileges on *.* to 'root'@'%' identified by '123456';

But error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '123456' at line 1

Solution:

use mysql;
update user set host ='%' where user ='root';
flush privileges;

Then an error is reported when connecting with Navicat

Client does not support authentication protocol requested by server; consider upgrading MySQL client

Solution:

ALTER USER 'root'@'*' IDENTIFIED WITH mysql_native_password BY '123456';

Recommended Posts

Install mysql8.0.13 version under Linux CentOS7 system
Install MySQL under Linux (CentOS 7)
Install mysql5.7 under CentOS7
Install mysql under Centos 7
Install mysql5.1 under CentOS6.5
Install MySQL 8.0.16 on Linux Centos
CentOS 6.8 under linux install mongodb
Install MySQL on Linux CentOS7 (Windows)
CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
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
Install linux (ubuntu) dual system under windows system
CentOS7 system yum way to install MySQL5.7
CentOS6.5 offline install MySQL5.6.26
Install mysql under Ubuntu 16.04
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Linux Centos7 install jdk1.8
CentOS 7.2 Yum install MySQL 5.6
CentOS (linux) install PostgreSQL
Centos7 install Mysql8 tutorial
VirtualBox install CentOS system
Centos manually install mysql8
Centos7 install Mysql database
Install Jenkins under Centos 7
Install MariaDB under MariaDB Centos7
Install MySQL under Ubuntu
Centos 7 install JDK (Linux install jdk)
Install MySQL 5.7 under CentOS 7 for middle class children!
Install MySQL 8.x from source code under CentOS7
Linux (CentOS7) using RPM to install mysql 8.0.11 tutorial
How to install Linux CentOS 7.7 system through VMware
Install mysql online on centos
Know Linux and install CentOS
centos install mysql through yum
Install python environment under Linux
Centos install high version GCC
Install Oracle11gR2 database under CentOS6.9
3 partitioning tools under CentOS Linux
Install docker on Centos system
Install Java JDK8 under CentOS6
Centos6 install mysql 5.7.x series
How to quickly install docker on Linux (Centos version)
Compile and install Lnmp shell script under Linux centos
Install MongoDB database under CentOS7
Centos7 install k8s cluster 1.15.0 version
CentOS 8.0.1905 install ZABBIX4.4 version (verified)
Centos7.6 install MySQL+Redis (latest version)
CentOS8 install MySQL8 (pro test)
Linux centos system boot process
Install Mesos tutorial under CentOS7
[Video] Teach you how to install the latest Linux version of QQ under Centos 8
Talk about | Install and use Linux system Ubuntu under Win10
How to install JDK and Mysql on Ubuntu 18.04 linux system