温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Mysql安装过程是怎样的

发布时间:2021-09-28 11:45:10 来源:亿速云 阅读:118 作者:柒染 栏目:MySQL数据库

这篇文章给大家介绍Mysql安装过程,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

环境说明:
操作系统:Red Hat Linux 6
安装Mysql5.7版本

安装须知:
一、准备mysql的安装包
二、准备好安装环境

操作指导:
一、下载mysql的安装包
https://www.mysql.com/downloads/ 访问mysql下载地址,进行如下操作进行下载。

Mysql安装过程是怎样的

Mysql安装过程是怎样的

Mysql安装过程是怎样的

Mysql安装过程是怎样的

将下载好的mysql安装包放到自己建立的安装目录下,进行解压。

[root@root /]# cd /soft/
[root@root soft]# ll
总用量 1151432
-rw-r--r--. 1 root root  227512320 8月   7 17:59 MySQL-5.6.41-1.el6.x86_64.rpm-bundle.tar
-rw-r--r--. 1 root root  475770880 8月   7 18:21 mysql-5.7.23-1.el6.x86_64.rpm-bundle.tar
-rw-r--r--. 1 7155 31415  24024136 6月  11 11:21 mysql-community-client-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415    340072 6月  11 11:21 mysql-community-common-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   3736628 6月  11 11:21 mysql-community-devel-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415  39496088 6月  11 11:21 mysql-community-embedded-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 137638820 6月  11 11:21 mysql-community-embedded-devel-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   2192692 6月  11 11:21 mysql-community-libs-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415   1723712 6月  11 11:21 mysql-community-libs-compat-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 160480880 6月  11 11:21 mysql-community-server-5.7.23-1.el6.x86_64.rpm
-rw-r--r--. 1 7155 31415 106124936 6月  11 11:21 mysql-community-test-5.7.23-1.el6.x86_64.rpm

二、准备好安装环境
检查当前系统下是否有mysql服务,方法: rpm -qa | grep mysql。 如果有就用rpm卸载掉。可以使用的命令是 rpm -ev 程序(如果卸载报存在依赖关系问题就用,rpm -e --nodeps 程序 进行卸载, --nodeps 跳过依赖关系)

[root@root mysql]# rpm -qa | grep mysql
mysql-libs-5.1.71-1.el6.x86_64
root@root mysql]# rpm -ev mysql-libs-5.1.71-1.el6.x86_64  /*报依赖关系*/
error: Failed dependencies:
        libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
        libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
[root@root soft]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64  /*卸载不含依赖关系*/
[root@root soft]#

三、进行mysql服务安装
进入到mysql包的解压目录下,用rpm进行安装。注意安装顺序,否则或报依赖关系错误。

[root@root soft]# rpm -ivh mysql-community-common-5.7.23-1.el6.x86_64.rpm
[root@root soft]# rpm -ivh mysql-community-libs-5.7.23-1.el6.x86_64.rpm
[root@root soft]# rpm -ivh mysql-community-client-5.7.23-1.el6.x86_64.rpm
[root@root soft]# rpm -ivh mysql-community-server-5.7.23-1.el6.x86_64.rpm

安装完成,修改配置文件。在/etc/my.cnf

[root@root etc]# vim my.cnf
[mysqld]
skip-grant-tables  /*添加,作用可以不用密码进行登录*/

启动mysql服务,输入mysql就可以进入数据库。(启用成功可以用 netstat -nlap | grep mysql  查看mysql服务)

[root@root soft]# service mysqld start
[root@root soft]# mysql  
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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>

这时,你可以使用navicat工具连接mysql服务了。如果连接不上,请检查3306端口是否开发,可以尝试关闭linux防火墙。service iptables stop

尝试连接成功后,我们可以为mysql服务设置密码。
先选择用户

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set authentication_string = password('111111'), password_expired = 'N', password_last_changed = now() where user = 'root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1
mysql> flush privileges; /*刷入配置,必须执行,否则后期错误信息*/
Query OK, 0 rows affected (0.00 sec)
mysql>

注:这个设置密码方式如果不对,可以尝试其它方法设置密码(如:mysqladmin -u root password “11111111”)。设置完密码切记要去my.cnf配置文件把skip-grant-tables 注释掉,在重启mysql服务。这是就可使用用户名密码登录。

关于Mysql安装过程就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI