Linux/centos7安装mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar步骤

因为做了一个网站,需要用到mysql数据库,然后自己倒腾下在我的centos7服务器上从0开始安装mysql数据库,安装mysql的方式有很多种,在线安装的方式我已经在另外一篇文章写过了,感兴趣的可以看那篇文章,今天主要讲述的是通过mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar安装包安装。

mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar下载:

链接:https://pan.baidu.com/s/1FLdXXFNI1kmUIdpsjtYTxQ 
提取码:g3mt  (链接不可用请直接留言即可)

1.如果之前安装过,则先使用如下命令卸载mysql,没有安装过,则跳过这步。

rpm -qa | grep -i mysql

rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

2.将下载好的安装包 通过xshell工具上传到服务器目录下,我的是放在/opt/local/mysql

3.解压操作

tar xvf mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar

4.解压完成后,会多出好几个安装文件,然后把压缩包给删了。

5.安装对应的包(必须按照顺序)

 rpm -ivh mysql-community-common-5.7.25-1.el6.x86_64.rpm 

 rpm -ivh mysql-community-libs-5.7.25-1.el6.x86_64.rpm 

 rpm -ivh mysql-community-devel-5.7.25-1.el6.x86_64.rpm 

 rpm -ivh mysql-community-client-5.7.25-1.el6.x86_64.rpm 

 rpm -ivh mysql-community-server-5.7.25-1.el6.x86_64.rpm 

在安装上述文件时会报失败,那是因为安装包与mariadb包冲突了,所以我们得先卸载mariadb包,然后再继续执行安装文件,例如我安装mysql-community-libs-5.7.25-1.el6.x86_64.rpm文件时就报如下错误,

warning: mysql-community-libs-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.21-1.el7.x86_64
mariadb-libs is obsoleted by mysql-community-libs-5.7.21-1.el7.x86_64

6.查看包命令rpm -qa |grep -i mariadb,然后卸载yum remove mariadb-libs-5.5.64-1.el7.x86_64

执行完之后再执行命令rpm -ivh mysql-community-libs-5.7.25-1.el6.x86_64.rpm 就可以正常安装了。

7.执行rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm 报错解决方法,报错如下:

error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.21-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.21-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.21-1.el7.x86_64

执行命令yum install libaio安装即可,然后再执行server安装命令

8.启动mysql

service mysqld start(第一次可能会失败,再试一次即可)
9.获取mysql初始化密码
grep 'temporary password' /var/log/mysqld.log

获取密码之后,然后用mysql -u root  -p '密码'登录mysql,登录之后会提示进行密码修改,修改命令如下:

SET PASSWORD = PASSWORD('XXXXXXX');

10.数据库查看编码

mysql>SHOW VARIABLES LIKE '%char%';

mysql> SHOW VARIABLES LIKE '%char%';
+--------------------------------------+----------------------------+
| Variable_name | Value |
+--------------------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
| validate_password_special_char_count | 1 |
+--------------------------------------+----------------------------+
9 rows in set (0.01 sec)

发现字符编码有latin1

11.修改/etc/my.cnf (默认在这个目录)

添加如下配置

[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8

12.重启mysql

service mysqld restart

13.开机自动启动mysql服务配置

systemctl enable mysqld

14.如果想远程访问服务器数据库,则如下配置

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>  Flush privileges;

分享到:

未经允许不得转载:just.do.it专注java开发 » Linux/centos7安装mysql-5.7.25-1.el6.x86_64.rpm-bundle.tar步骤

赞 (1) 打赏

评论 0

评论前必须登录!

登陆 注册

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

Optimized by WPJAM Basic