搜索
首页数据库mysql教程教你怎么在线安装Mysql
教你怎么在线安装MysqlSep 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中文网其他相关文章!

声明
本文转载于:segmentfault。如有侵权,请联系admin@php.cn删除
图文详解mysql架构原理图文详解mysql架构原理May 17, 2022 pm 05:54 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

mysql的msi与zip版本有什么区别mysql的msi与zip版本有什么区别May 16, 2022 pm 04:33 PM

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

mysql怎么去掉第一个字符mysql怎么去掉第一个字符May 19, 2022 am 10:21 AM

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

mysql怎么替换换行符mysql怎么替换换行符Apr 18, 2022 pm 03:14 PM

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

mysql怎么将varchar转换为int类型mysql怎么将varchar转换为int类型May 12, 2022 pm 04:51 PM

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

MySQL复制技术之异步复制和半同步复制MySQL复制技术之异步复制和半同步复制Apr 25, 2022 pm 07:21 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

mysql怎么判断是否是数字类型mysql怎么判断是否是数字类型May 16, 2022 am 10:09 AM

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

带你把MySQL索引吃透了带你把MySQL索引吃透了Apr 22, 2022 am 11:48 AM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

See all articles

热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尊渡假赌尊渡假赌尊渡假赌

热工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

禅工作室 13.0.1

禅工作室 13.0.1

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