Linux(CentOS 7)中安装mysql-5.5.62

1,下载

https://dev.mysql.com/downloads/mysql/5.5.html

注意:Select Operating System: Red Hat Enterprise Linux / Oracle Linux

例如:MySQL-server-5.5.62-1.el7.x86_64.rpm

MySQL-client-5.5.62-1.el7.x86_64.rpm

2,安装 (这里的安装操作时基于SecureCRT工具完成的)

1,把下载好的MySQL-server-5.5.62-1.el7.x86_64.rpm 和 MySQL-client-5.5.62-1.el7.x86_64.rpm 直接拖进/opt目录下。
2,rpm -ivh MySQL-server-5.5.62-1.el7.x86_64.rpm
3,rpm -ivh MySQL-client-5.5.62-1.el7.x86_64.rpm
4,添加mysql用户和用户组

1,useradd mysql

2,groupadd mysql

5,查看安装是否成功

mysqladmin --version

mysqladmin Ver 9.0 Distrib 5.5.64-MariaDB, for Linux on x86_64 ------> 表示安装成功

6,启动mysql

systemctl start mysql.service

Failed to start mysql.service: Unit not found. --------> 出现问题不要着急

7,解决上面问题

在CentOS7中已经不在支持mysql,就算你已经安装了,CentOS7还是表示很嫌弃

yum install -y mariadb-server

Transaction check error: -------> 执行上面命令,出现这个问题,说明版本冲突,仔细查看上面显示的问题

rpm -e 出现问题的版本 -------> 删除出现问题的版本

例如:rpm -e MySQL-client-5.5.62-1.el7.x86_64.rpm

再次执行 yum install -y mariadb-server

8,开启mysql服务

systemctl start mariadb.service

可能会出现 ---------> Job for mariadb.service failed because the control process exited with error code. See “systemctl status mariadb.service” and “journalctl -xe” for details.

解决问题:cp /usr/share/mysql/my-huge.cnf /etc/my.cnf

3,为mysql设置密码

/usr/bin/mysqladmin -u root password 123

登陆mysql

mysql -u root -p

Enter password: 123

显示如下登陆成功:

Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 7 Server version: 5.5.64-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>

4,设置mysql开机自动启动

systemctl enable mariadb.service

5,解决数据中文乱码问题

首先将mysql的配置文件my-huge.cnf复制到/etc下

cp /usr/share/mysql/my-huge.cnf /etc/my.cnf

在/etc/my.cnf/ 下添加如下代码:

[client]

default-character-set=utf8

[mysqld]

character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci

[mysql]

default-character-set=utf8

posted @ 2019-11-17 12:11  文所未闻  阅读(1544)  评论(0编辑  收藏  举报