安装mysql8.0问题记录 Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/b...safe)

安装mysql8.0
创建存放二进制软件包的目录

 mkdir -p /data/app

上传软件包并解压

mv /root/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz   /data/app/
cd /data/app/
 tar xf  mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz

创建软连接

ln -s mysql-8.0.18-linux-glibc2.12-x86_64 mysql

写入环境变量

vim /etc/profile
[root@zabbix ~]# tail -1  /etc/profile
PATH=/data/app/mysql/bin:$PATH
[root@zabbix ~]#

并生效

 source /etc/profile

验证

mysql -V
mysql  Ver 8.0.18 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)

查看是否已经安装数据库服务

rpm -qa mariadb

查看是否有my.cnf文件,如果有就删除掉

ll /etc/my.cnf
rm -rf /etc/my.cnf

下载依赖包

yum install -y libaio-devel

创建存放数据的目录

mkdir -p /data/3306/data

创建用户

 useradd -M  -s /sbin/nologin  mysql

属主属组设为mysql

chown -R mysql.mysql  /data/

初始化配置

 mysqld       --initialize-insecure      --user=mysql      --basedir=/data/app/mysql        --datadir=/data/3306/data

准备配置文件

[root@zabbix ~]# cat /etc/my.cnf
[mysqld]
user=mysql
basedir=/data/app/mysql
datadir=/data/3306/data
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
[root@zabbix ~]#

使用systemctl方式管理mysql

cp /data/app/mysql/support-files/mysql.server  /etc/init.d/mysqld
 chkconfig --add mysqld
systemctl start msyqld

问题:进行上面操作以后,发现无法启动的问题

[root@zabbix ~]# systemctl status  mysqld
● mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
   Active: inactive (dead) since Tue 2020-04-21 21:24:14 EDT; 1min 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8786 ExecStop=/etc/rc.d/init.d/mysqld stop (code=exited, status=0/SUCCESS)

Apr 21 21:07:01 zabbix systemd[1]: Starting LSB: start and stop MySQL...
Apr 21 21:07:01 zabbix mysqld[8492]: my_print_defaults: [ERROR] Found option without preceding group in c...ne 1.
Apr 21 21:07:01 zabbix mysqld[8492]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program...rted!
Apr 21 21:07:01 zabbix mysqld[8492]: /etc/rc.d/init.d/mysqld: line 259: cd: /usr/local/mysql: No such fil...ctory
Apr 21 21:07:01 zabbix mysqld[8492]: Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/b...safe)
Apr 21 21:07:01 zabbix systemd[1]: Started LSB: start and stop MySQL.
Apr 21 21:24:14 zabbix systemd[1]: Stopping LSB: start and stop MySQL...
Apr 21 21:24:14 zabbix mysqld[8786]: ERROR! MySQL server PID file could not be found!
Apr 21 21:24:14 zabbix systemd[1]: Stopped LSB: start and stop MySQL.
Hint: Some lines were ellipsized, use -l to show in full.

使用这样的方式可以启动。

service mysqld start
[root@zabbix ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.18 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

原因分析:

你可能感兴趣的:(小型服务)