Mysql安装过程是怎样的
admin
2023-04-25 06:42:26
0

环境说明:
操作系统: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服务。这是就可使用用户名密码登录。

相关内容

热门资讯

核查:上世纪已有多款汉坦疫苗上... 明查员 冯梦速览- 人类感染汉坦病毒已有数十年历史。朝鲜战争期间,联合国军就曾有过大规模感染。汉坦病...
如何从“一证在手”走向“一技傍... 教员在给学员讲解理论知识。 学员在进行无人机试飞训...
内蒙古自治区党委金融工作委员会... 内蒙古自治区党委金融工作委员会副书记马保国涉嫌严重违纪违法,目前正接受内蒙古自治区纪委监委纪律审查和...
涉非市场化发债,老牌房企花样年... 【大河财立方消息】 5月12日,深圳证监局发布行政监管措施决定书显示,花样年集团(中国)有限公司因非...
郑州市今年计划新入库45个城市... 【大河财立方消息】5月12日,郑州市城乡建设局就《郑州市2026年度城市更新计划(征求意见稿)》公开...
让无名者有名,让英雄回家!湖南... 1948年秋冬,辽沈战役的硝烟刚刚散去,一大批东北子弟兵随军南下。不到一年后,1949年8月,300...
伊方透露新一轮谈判先决条件 当地时间12日,伊朗方面发布消息称,一名知情人士透露了伊朗同美国新一轮谈判的五项先决条件 ——即“结...
中东危机下,莫迪将密集访问5国 【环球时报驻巴基斯坦特约记者 黄晓娜】印度外交部11日宣布,印度总理莫迪将于15日开始对阿联酋、荷兰...
“台独”顽固分子沈伯洋参选台北... 【环球时报特约记者 陈立非】台湾今年年底举行“九合一”选举,国民党很早就确定由现任台北市市长蒋万安争...