目录
一、 检查系统中是否已安装了mysql服务或开发包依赖等
二、检查yum源上可以使用的安装包(如果对mysql版本有要求,可以修改yum源的配置)
三、安装mysql-server ,使用yum install 命令,安装过程中会自动把所有依赖的包自动下载和安装
四、启动mysqld服务
五、使用mysql数据库
首页 数据库 mysql教程 教你怎么在线安装Mysql

教你怎么在线安装Mysql

Sep 16, 2021 pm 03:53 PM
mysql

一、 检查系统中是否已安装了mysql服务或开发包依赖等

[bigdata@bigdata-pro02 ~]$ rpm -qa | grep mysql
mysql-libs-5.1.73-3.el6_5.x86_64
登录后复制

如果检查存在一些安装包,则使用 rpm -e --nodeps [安装包1] [安装包2] [...] 将已有的安装包卸载。
这里需要切换到root用户

[root@bigdata-pro02 ~]# rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64
[root@bigdata-pro02 ~]#
登录后复制

二、检查yum源上可以使用的安装包(如果对mysql版本有要求,可以修改yum源的配置)

使用yum list | grep mysql 来检查可以使用的安装包

[root@bigdata-pro02 ~]# yum list | grep mysql-server
mysql-server.x86_64                            5.1.73-8.el6_8               @base
登录后复制

三、安装mysql-server ,使用yum install 命令,安装过程中会自动把所有依赖的包自动下载和安装

[root@bigdata-pro02 ~]# yum install mysql-server.x86_64 -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink                                                                                | 4.9 kB     00:00     
 * base: mirrors.163.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                                                         | 3.7 kB     00:00     
epel                                                                                         | 3.2 kB     00:00     
epel/primary                                                                                 | 3.2 MB     00:01     
epel                                                                                                    12521/12521
extras                                                                                       | 3.4 kB     00:00     
updates                                                                                      | 3.4 kB     00:00     
updates/primary_db                                                                           | 1.2 MB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be installed
--> Processing Dependency: mysql = 5.1.73-8.el6_8 for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be installed
---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================
 Package                        Arch                   Version                           Repository            Size
====================================================================================================================
Installing:
 mysql-server                   x86_64                 5.1.73-8.el6_8                    base                 8.6 M
Installing for dependencies:
 mysql                          x86_64                 5.1.73-8.el6_8                    base                 895 k
 mysql-libs                     x86_64                 5.1.73-8.el6_8                    base                 1.2 M
 perl-DBD-MySQL                 x86_64                 4.013-3.el6                       base                 134 k
 perl-DBI                       x86_64                 1.609-4.el6                       base                 705 k

Transaction Summary
====================================================================================================================
Install       5 Package(s)

Total download size: 12 M
Installed size: 33 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): mysql-5.1.73-8.el6_8.x86_64.rpm                                                       | 895 kB     00:00     
(2/5): mysql-libs-5.1.73-8.el6_8.x86_64.rpm                                                  | 1.2 MB     00:00     
(3/5): mysql-server-5.1.73-8.el6_8.x86_64.rpm                                                | 8.6 MB     00:03     
(4/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                 | 134 kB     00:00     
(5/5): perl-DBI-1.609-4.el6.x86_64.rpm                                                       | 705 kB     00:00     
--------------------------------------------------------------------------------------------------------------------
Total                                                                               2.4 MB/s |  12 MB     00:04     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of libmysqlclient.so.16()(64bit)
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)
2:postfix-2.6.6-6.el6_5.x86_64 has missing requires of mysql-libs
  Installing : mysql-libs-5.1.73-8.el6_8.x86_64                                                                 1/5 
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                      2/5 
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                3/5 
  Installing : mysql-5.1.73-8.el6_8.x86_64                                                                      4/5 
  Installing : mysql-server-5.1.73-8.el6_8.x86_64                                                               5/5 
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                1/5 
  Verifying  : mysql-libs-5.1.73-8.el6_8.x86_64                                                                 2/5 
  Verifying  : mysql-server-5.1.73-8.el6_8.x86_64                                                               3/5 
  Verifying  : mysql-5.1.73-8.el6_8.x86_64                                                                      4/5 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                      5/5 

Installed:
  mysql-server.x86_64 0:5.1.73-8.el6_8                                                                              

Dependency Installed:
  mysql.x86_64 0:5.1.73-8.el6_8     mysql-libs.x86_64 0:5.1.73-8.el6_8     perl-DBD-MySQL.x86_64 0:4.013-3.el6    
  perl-DBI.x86_64 0:1.609-4.el6    

Complete!
登录后复制

检查系统中是否安装mysql

[root@bigdata-pro02 ~]# rpm -qa | grep mysql
mysql-5.1.73-8.el6_8.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64
登录后复制

检查mysql命令所在位置

[root@bigdata-pro02 ~]# which mysql
/usr/bin/mysql
登录后复制

四、启动mysqld服务

[root@bigdata-pro02 ~]# service mysqld status
mysqld is stopped
[root@bigdata-pro02 ~]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h bigdata-pro02.mars.com password 'new-password'
**# 以上为两种新建root用户并设置密码的方式**

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
登录后复制

五、使用mysql数据库

添加root用户并设置密码

[root@bigdata-pro02 ~]# /usr/bin/mysqladmin -u root password '123456'
登录后复制

登录mysql数据库

[root@bigdata-pro02 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.01 sec)

mysql> create table test1 (id int(10), name varchar(20) ) ;
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test1          |
+----------------+
1 row in set (0.00 sec)
登录后复制

推荐学习:《mysql视频教程

以上是教你怎么在线安装Mysql的详细内容。更多信息请关注PHP中文网其他相关文章!

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

mysql用户和数据库的关系 mysql用户和数据库的关系 Apr 08, 2025 pm 07:15 PM

MySQL 数据库中,用户和数据库的关系通过权限和表定义。用户拥有用户名和密码,用于访问数据库。权限通过 GRANT 命令授予,而表由 CREATE TABLE 命令创建。要建立用户和数据库之间的关系,需创建数据库、创建用户,然后授予权限。

RDS MySQL 与 Redshift 零 ETL 集成 RDS MySQL 与 Redshift 零 ETL 集成 Apr 08, 2025 pm 07:06 PM

数据集成简化:AmazonRDSMySQL与Redshift的零ETL集成高效的数据集成是数据驱动型组织的核心。传统的ETL(提取、转换、加载)流程复杂且耗时,尤其是在将数据库(例如AmazonRDSMySQL)与数据仓库(例如Redshift)集成时。然而,AWS提供的零ETL集成方案彻底改变了这一现状,为从RDSMySQL到Redshift的数据迁移提供了简化、近乎实时的解决方案。本文将深入探讨RDSMySQL零ETL与Redshift集成,阐述其工作原理以及为数据工程师和开发者带来的优势。

mysql 是否要付费 mysql 是否要付费 Apr 08, 2025 pm 05:36 PM

MySQL 有免费的社区版和收费的企业版。社区版可免费使用和修改,但支持有限,适合稳定性要求不高、技术能力强的应用。企业版提供全面商业支持,适合需要稳定可靠、高性能数据库且愿意为支持买单的应用。选择版本时考虑的因素包括应用关键性、预算和技术技能。没有完美的选项,只有最合适的方案,需根据具体情况谨慎选择。

如何针对高负载应用程序优化 MySQL 性能? 如何针对高负载应用程序优化 MySQL 性能? Apr 08, 2025 pm 06:03 PM

MySQL数据库性能优化指南在资源密集型应用中,MySQL数据库扮演着至关重要的角色,负责管理海量事务。然而,随着应用规模的扩大,数据库性能瓶颈往往成为制约因素。本文将探讨一系列行之有效的MySQL性能优化策略,确保您的应用在高负载下依然保持高效响应。我们将结合实际案例,深入讲解索引、查询优化、数据库设计以及缓存等关键技术。1.数据库架构设计优化合理的数据库架构是MySQL性能优化的基石。以下是一些核心原则:选择合适的数据类型选择最小的、符合需求的数据类型,既能节省存储空间,又能提升数据处理速度

MySQL 中的查询优化对于提高数据库性能至关重要,尤其是在处理大型数据集时 MySQL 中的查询优化对于提高数据库性能至关重要,尤其是在处理大型数据集时 Apr 08, 2025 pm 07:12 PM

1.使用正确的索引索引通过减少扫描的数据量来加速数据检索select*fromemployeeswherelast_name='smith';如果多次查询表的某一列,则为该列创建索引如果您或您的应用根据条件需要来自多个列的数据,则创建复合索引2.避免选择*仅选择那些需要的列,如果您选择所有不需要的列,这只会消耗更多的服务器内存并导致服务器在高负载或频率时间下变慢例如,您的表包含诸如created_at和updated_at以及时间戳之类的列,然后避免选择*,因为它们在正常情况下不需要低效查询se

mysql怎么复制粘贴 mysql怎么复制粘贴 Apr 08, 2025 pm 07:18 PM

MySQL 中的复制粘贴包含以下步骤:选择数据,使用 Ctrl C(Windows)或 Cmd C(Mac)复制;在目标位置右键单击,选择“粘贴”或使用 Ctrl V(Windows)或 Cmd V(Mac);复制的数据将插入到目标位置,或替换现有数据(取决于目标位置是否已存在数据)。

mysql怎么查看 mysql怎么查看 Apr 08, 2025 pm 07:21 PM

通过以下命令查看 MySQL 数据库:连接到服务器:mysql -u 用户名 -p 密码运行 SHOW DATABASES; 命令获取所有现有数据库选择数据库:USE 数据库名;查看表:SHOW TABLES;查看表结构:DESCRIBE 表名;查看数据:SELECT * FROM 表名;

了解 ACID 属性:可靠数据库的支柱 了解 ACID 属性:可靠数据库的支柱 Apr 08, 2025 pm 06:33 PM

数据库ACID属性详解ACID属性是确保数据库事务可靠性和一致性的一组规则。它们规定了数据库系统处理事务的方式,即使在系统崩溃、电源中断或多用户并发访问的情况下,也能保证数据的完整性和准确性。ACID属性概述原子性(Atomicity):事务被视为一个不可分割的单元。任何部分失败,整个事务回滚,数据库不保留任何更改。例如,银行转账,如果从一个账户扣款但未向另一个账户加款,则整个操作撤销。begintransaction;updateaccountssetbalance=balance-100wh

See all articles