Linux CentOS7系统下安装mysql8.0.13版本
前言
最近整理下在Linux CentOS7系统下安装mysql8.0.13版本的一些步骤和遇到的问题,分享给大家!
一
安装和报错处理
1.进入到https://www.mysql.com/downloads/msyql下载页,选择社区版
2.查看linux版本,选择对应的版本下载
3.将下载的文件mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz拷贝到linux服务器上的某目录下,然后解压,再复制到usr/local目录,并改名为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
4.添加mysql用户
useradd -s /sbin/nologin -M mysql
5.msyql初始化
/usr/local/mysql/bin/mysqld --initialize --user=mysql
此时会生成临时密码
[root@VM_0_14_centos mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql
2019-01-20T10:56:07.718326Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.13) initializing of server in progress as process 5826
2019-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
6.复制启动、关闭脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
7.修改配置文件,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
8.启动数据库服务
service mysqld start
报错
mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
一是因为没有/var/lib/mysql这个目录,二是没有写的权限,mysql.sock文件无法生成。
[root@VM_0_14_centos lib]# mkdir mysql
[root@VM_0_14_centos lib]# chmod 777 /var/lib/mysql
再次运行service mysqld start报另一个错
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/VM_0_14_centos.pid).
打印出具体报错信息
[root@VM_0_14_centos mysql]# cat VM_0_14_centos.err
2019-01-20T11:11:45.906800Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.13) starting as process 7788
2019-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-20T11: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 7975
2019-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