关于centos7.8.2安装mysql5.6.38的奇遇

安装步骤就不多说了,直接跳到安装MySQL-server-5.6.38-1.el7.x86_64.rpm,下面就是操作的错误提示

[root@127 mysql]# rpm -ivh MySQL-client-5.6.38-1.el7.x86_64.rpm
警告:MySQL-client-5.6.38-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-client-5.6.38-1.el7        ################################# [100%]
[root@127 mysql]# rpm -ivh MySQL-devel-5.6.38-1.el7.x86_64.rpm
警告:MySQL-devel-5.6.38-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-devel-5.6.38-1.el7         ################################# [100%]
[root@127 mysql]# rpm -ivh MySQL-server-5.6.38-1.el7.x86_64.rpm
警告:MySQL-server-5.6.38-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-server-5.6.38-1.el7        ################################# [100%]
mkdir: 无法创建目录"/usr/local/mysql/data": 没有那个文件或目录
mkdir: 无法创建目录"/usr/local/mysql/data/mysql": 没有那个文件或目录
mkdir: 无法创建目录"/usr/local/mysql/data/test": 没有那个文件或目录
/var/tmp/rpm-tmp.e4S3qx:行32: /usr/local/mysql/data/RPM_UPGRADE_MARKER: 没有那个文件或目录
chown: 无法访问"/usr/local/mysql/data": 没有那个文件或目录
FATAL ERROR: The parent directory for the data directory '/usr/local/mysql/data' does not exist.
If that path was really intended, please create that directory path and then
restart this script.
If some other path was intended, please use the correct path when restarting this script.
chown: 无法访问"/usr/local/mysql/data": 没有那个文件或目录
chmod: 无法访问"/usr/local/mysql/data/mysql": 没有那个文件或目录
/var/tmp/rpm-tmp.e4S3qx:行146: /usr/local/mysql/data/RPM_UPGRADE_MARKER: 没有那个文件或目录
/var/tmp/rpm-tmp.e4S3qx:行147: /usr/local/mysql/data/RPM_UPGRADE_MARKER: 没有那个文件或目录
/var/tmp/rpm-tmp.e4S3qx:行148: /usr/local/mysql/data/RPM_UPGRADE_MARKER: 没有那个文件或目录
/var/tmp/rpm-tmp.e4S3qx:行150: /usr/local/mysql/data/RPM_UPGRADE_HISTORY: 没有那个文件或目录
mv: 无法获取"/usr/local/mysql/data/RPM_UPGRADE_MARKER" 的文件状态(stat): 没有那个文件或目录
警告:%post(MySQL-server-5.6.38-1.el7.x86_64) 脚本执行失败,退出状态码为 1

 

因为当时也就找一个教程来,按步骤来安装,我也不知道对方是不是centos7,反正到了这步,就对不上教程了。看提示说

mkdir: 无法创建目录"/usr/local/mysql/data": 没有那个文件或目录,于是我查询了下,/usr/local/目录连mysql都没有,那mkdir可能是因为这个原因,创建data目录失败,后面的提示也是因为这个原因引起的。

      找到原因了那就重来,把装了的mysql全部卸载,打以下命令查看

rpm -qa | grep -i mysql

[root@127 mysql]# rpm -qa | grep -i mysql
MySQL-client-5.6.38-1.el7.x86_64
MySQL-server-5.6.38-1.el7.x86_64
MySQL-devel-5.6.38-1.el7.x86_64

把 这3个依次用命令

yum -y remove MySQL-client-5.6.38-1.el7.x86_64

yum -y remove MySQL-server-5.6.38-1.el7.x86_64

yum -y remove MySQL-devel-5.6.38-1.el7.x86_64

再用find / -name mysql把mysql的目录找到,然后删除。

 现在开始重新安装,先在/usr/local/中建一个mysql目录,接着按下面顺序

rpm -ivh MySQL-devel-5.6.38-1.el7.x86_64.rpm

rpm -ivh MySQL-client-5.6.38-1.el7.x86_64.rpm

rpm -ivh MySQL-server-5.6.38-1.el7.x86_64.rpm

安装完成后,是一大批英文


A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the servern

居然忘记删除配置文件my.cnf,先不管,运行systemctl netstart mysqld 

提示错误不能运行,这个也先不管,打个命令试试mysql -u root -p

这个终于弹出一个有详细提示的错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

直接百度一下,找到了以下解决方法([]里的文字是我操作经过)

首先进入超级用户root权限 sudo -i 或者su - root

  切换到默认目录 cd /var/lib/mysql 下查看一下该文件是否存在(可以再次目录下执行以下操作)。[我查询了,没有]

  执行命令 ps -aux | grep mysql

  查看正在运行的进程,把进程杀死(mysql进程)

  执行命令 kill 进程ID [有进程,半天没杀死,后来直接跳过]

  在root权限下执行 vim/vi /etc/mysql/my.cnf ,打开配置文件之后将自己添加的数据删除掉,恢复最原始的配置文件内容。[首先我的地址跟它的不一样,反正我就找到my.cnf把它还原了]

  执行sudo service mysql start ,就会出现 mysql start/running, process 6106,说明mysql服务启动成功!
[我执行的结果跟它的不一样,但有提示SUCCESS,那就是成功了]

mysql服务终于成功启动,安装还没结束,先把初始密码改了,找那段英文提示,我打入命令cat /root/.mysql_secret

# The random password set for the root user at Sat May  9 15:38:31 2020 (local time): id1EADPNz9YLNevT

# The random password set for the root user at Sat May  9 16:20:37 2020 (local time): ku3sFmSwwNKRmSYY

# The random password set for the root user at Sat May  9 16:29:04 2020 (local time): DmudCNs4SjjMbgtk

# The random password set for the root user at Sat May  9 17:08:45 2020 (local time): xGlybDBq1qiLK2wg
 

找到最后时间的那个,原来我装了这么多次,终于来这一步了,接着又是命令

mysql -u root -p

输入xGlybDBq1qiLK2wg ,终于弹出登录成功

Server version: 5.6.38

Copyright (c) 2000, 2017, 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> use mysql
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement#要重置密码

mysql> SET PASSWORD = PASSWORD('123456abc');#设置密码
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;#授权登录
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

至此才算大功告成,这就是centos7.8.2下安装mysql5.6.38的不一样的遭遇!很难找到与教程一样顺的操作!


 

你可能感兴趣的:(关于centos7.8.2安装mysql5.6.38的奇遇)