CentOS6上安装数据库的方法 (centos6数据库安装)

CentOS6是一种免费、开源的Linux操作系统,适用于服务器和桌面应用程序开发。随着企业和组织对大数据的需求不断增加,安装数据库已成为服务器设置的必要部分。本文将介绍在。

选择适合你的数据库

在将数据库安装到CentOS6系统之前,你需要选择一种适合你的数据库。目前大多数企业和组织都选择MySQL或PostgreSQL数据库,因为它们是免费的、开源的和易于使用的数据库。其他的数据库包括Oracle、MongoDB和SQL Server。你需要根据你的需求选择适合你的数据库。

MySQL数据库的安装

MySQL数据库是一个流行的、开源的关系型数据库管理系统。它支持多用户、多线程,并且能够处理大量的数据。以下是在CentOS6上安装MySQL数据库的步骤:

1.打开终端并切换到root用户。

2.使用以下命令更新CentOS6系统:yum update

3.使用以下命令将MySQL服务器和客户端软件包下载到CentOS6系统:

yum install mysql-server mysql

4.使用以下命令启动MySQL服务器:

service mysqld start

5.使用以下命令将MySQL服务器设置为在系统启动时自动启动:

chkconfig mysqld on

6.使用以下命令安装MySQL安全性脚本:

mysql_secure_installation

7.根据提示依次输入MySQL管理员密码和其他设置。

8.完成后,你可以进入MySQL数据库并开始使用它。

PostgreSQL数据库的安装

PostgreSQL数据库是一个强大的、开源的关系型数据库。它拥有高度的可扩展性和完备性,使其成为企业级应用程序的首选数据库。以下是在CentOS6上安装PostgreSQL数据库的步骤:

1.打开终端并切换到root用户。

2.使用以下命令更新CentOS6系统:yum update

3.使用以下命令安装PostgreSQL:

yum install postgresql-server postgresql-contrib

4.使用以下命令初始化数据库并启动PostgreSQL服务器:

service postgresql initdb

service postgresql start

5.使用以下命令将PostgreSQL服务器设置为在系统启动时自动启动:

chkconfig postgresql on

6.使用以下命令更改新用户的postgres用户密码:

passwd postgres

7.使用以下命令登录PostgreSQL:

su – postgres

psql

8.登录后,你可以创建自己的数据库和表,或者使用现有的数据库和表。

在CentOS6上安装数据库需要根据你的需求选择适合你的数据库。MySQL和PostgreSQL是两种常用的免费、开源的数据库,本文介绍了在CentOS6上安装MySQL和PostgreSQL的详细步骤。安装数据库之前,你需要更新你的CentOS6系统。安装数据库之后,你可以开始创建自己的数据库和表,并开始使用它。

相关问题拓展阅读:

  • centos6.5安装mysql cluster问题求助
  • centos6.6没有找到phpmyadmin怎么安装

centos6.5安装mysql cluster问题求助

mysql ndbcluster 安装

1.数据库规划:

操作系统 centos 6.3

ndbcluster 版本:MySQL-Cluster-gpl-7.4.8-1.el6.x86_64

2个管理节点、2个sql节点、2个数据节点(管理节点和sql节点放在同一台服务器上)

如下:

管理节点1 192.168.1.17

管理节点2 192.168.1.18

sql节点1 192.168.1.17

sql节点2 192.168.1.18

ndbd 节点1 192.168.1.19

ndbd 节点2 192.168.1.20

2.操雀桥作系统纤渣设置:

设置服务主机名称

关闭selinux和防火墙

设置内核参数和更大进程数

下载mysql集群

MySQL-Cluster-gpl-7.4.8-1.el6.x86_64.rpm-bundle.tar

上传到服务器的相应目录下如 /home/mysqlinstall

3.安装管理节点和sql节点:

To check if your system has any RPM version of any MySQL package currently installed, run:

shell> rpm -qa | grep -i mysql

检查

# rpm -qa | grep -i mysql

mysql-libs-5.1.61-4.el6.x86_64

如果有删除

shell> rpm -e mysql-libs-5.1.61-4.el6.x86_64

删除报错:

# rpm -e mysql-libs-5.1.61-4.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

mysql-libs is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64

#

解决:

# rpm -e –nodeps mysql-libs-5.1.61-4.el6.x86_64

#

# rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm

# rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm

4.安装数据节点:

执行上面步骤

# rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm

# rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm

5.配置集群

管理节点建立目录

mkdir /var/lib/mysql-cluster

mkdir -p /data/mysql/ndbdata

5.启动关闭集群:

启动管理节点

ndb_mgmd -f /var/lib/mysql-cluster/config.ini –initial (之一次启动加–initial修改了配置文件后的启动)

启动数据节点

ndbmtd –initial

启动sql节点

service mysql start

查看集群状态

shell> ndb_mgm -e “SHOW”

关闭管理节点和数据节点

ndb_mgm -e shutdown

关闭sql节点

service mysql stop

安装遇到的问题:

1.权限问题启动mysql报毁岁悄错

# service mysql start

Starting MySQL..The server quit without updating PID file (sql/sqlmgm2.pid).

#

# ll

total

-rw-rwmysql mysqlDec 14 17:13 auto.cnf

-rw-rwmysql mysqlDec 14 17:39 ibdata1

-rw-rwmysql mysqlDec 14 17:40 ib_logfile0

-rw-rwmysql mysqlDec 14 17:13 ib_logfile1

drwxmysql mysqlDec 14 17:39 mysql

drwxroot rootDec 14 17:39 ndbinfo

drwxroot rootDec 14 17:39 performance_schema

-rw-rmysql mysqlDec 14 17:40 sqlmgm2.err

drwxroot rootDec 14 17:33 test

# chown mysql:mysql -R mysql

# service mysql start

Starting MySQL..

#

2.安装rpm包时,报包依赖关系如下:

# rpm -ivh MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm

warning: MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

error: Failed dependencies:

libnuma.so.1()(64bit) is needed by MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64

libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_64

libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-Cluster-server-gpl-7.4.8-1.el6.x86_

解决方法是把安装的依赖的包

# yum install numactl

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

* base: mirrors.163.com

* extras: mirrors.opencas.cn

* updates: mirrors.opencas.cn

Setting up Install Process

Resolving Dependencies

–> Running transaction check

—> Package numactl.x86_64 0:2.0.9-2.el6 will be installed

–> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================

PackageArchVersion Repository Size

==============================================================================================================================

Installing:

numactlx86_.0.9-2.elbasek

Transaction Summary

==============================================================================================================================

InstallPackage(s)

Total download size: 74 k

Installed size: 171 k

Is this ok : y

Downloading Packages:

numactl-2.0.9-2.el6.x86_64.rpm | 74 kB:

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

Retrieving key from

Importing GPG key 0xC105B9DE:

Userid : CentOS-6 Key (CentOS 6 Official Signing Key)

Package: centos-release-6-3.el6.centos.9.x86_64 (@anaconda-CentOS.x86_64/6.3)

From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Is this ok : y

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : numactl-2.0.9-2.el6.x86_/1

Verifying : numactl-2.0.9-2.el6.x86_/1

Installed:

numactl.x86_64 0:2.0.9-2.el

Complete!

3.启动数据库节点无法和管理节点相连

原因由于防火墙和selinux没有关闭

解决关闭防火墙和selinux

一、关闭防火墙

1、重启后永久性生效:

开启:chkconfig iptables on

关闭:chkconfig iptables off

2、即时生效,重启后失效:

开启:service iptables start

关闭:service iptables stop

二、关闭SELinux

vim /etc/selinux/config # 改为 SELINUX=disabled

# 保存退出,重启服务器

init 6

禁用SeLinux

#永久禁用,需要重启生效。

sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

# 临时禁用,不需要重启

setenforce 0

4.root用户不能登录

# mysql -uroot -p

Enter password:

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)

# mysql -uroot -p

Enter password:

ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

设置–skip-grant-tables跳过授权表认证

service mysqld stop

在配置文件中添加–skip-grant-tables(/etc/my.cnf)

service mysqld start

另外开个SSH连接

# mysql

mysql>use mysql

mysql>update user set password=password(“123456″) where user=”root”;

mysql>flush privileges;

mysql>exit

去掉–skip-grant-tables重启mysql,root用户可以用设置的密码登录

设置root用户远程登录

GRANT ALL PRIVILEGES ON *.* TO root@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;

执行报如下错误,ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.27-ndb-7.4.8-cluster-gpl

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

mysql>

mysql> GRANT ALL PRIVILEGES ON *.* TO root@”%” IDENTIFIED BY ‘root’ WITH GRANT OPTION;

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> GRANT ALL PRIVILEGES ON *.* TO root@”%” IDENTIFIED BY ‘root001’ WITH GRANT OPTION;

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

执行SET PASSWORD修改成功

mysql> SET PASSWORD = PASSWORD(‘root001’);

Query OK, 0 rows affected (0.02 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO root@”%” IDENTIFIED BY ‘root’ WITH GRANT OPTION;

Query OK, 0 rows affected (0.02 sec)

mysql>

FLUSH PRIVILEGES;

执行完成

远程连接测试,mysql集群节点,发现一个节点可以连接,一个节点不能连接

这个问题纠结很久

原因上面的操作,没有在另外一个节点上执行导致的,mysql集群的用户认证是分开管理的,要两个节点都要执行

索引以后创建用户要两个节点都执行

5.配置两个管理节点时show报错Could not get configuration

# ndb_mgm

— NDB Cluster — Management Client —

ndb_mgm> show

Connected to Management Server at: 192.168.1.17:1186

ERROR Message: The cluster configuration is not yet confirmed by all defined management servers. This management server is still waiting for node 6 to connect.

Could not get configuration

* 4012: Failed to get configuration

*The cluster configuration is not yet confirmed by all defined management servers. This management server is still waiting for node 6 to connect.

ndb_mgm> show

Cluster Configuration

node(s)

id=2 (not connected, accepting connect from 192.168.1.18)

id=3 (not connected, accepting connect from 192.168.1.17)

2 node(s)

id=1 @192.168.1.17 (mysql-5.6.27 ndb-7.4.8)

id=6 @192.168.1.18 (mysql-5.6.27 ndb-7.4.8)

2 node(s)

id=4 (not connected, accepting connect from 192.168.1.17)

id=5 (not connected, accepting connect from 192.168.1.18)

两个管理节点同时都启动起来,才能看到状态

ndb_mgm> show

Cluster Configuration

node(s)

id=2 @192.168.1.18 (mysql-5.6.27 ndb-7.4.8, Nodegroup: 0, *)

id=3 @192.168.1.17 (mysql-5.6.27 ndb-7.4.8, Nodegroup: 0)

2 node(s)

id=1 @192.168.1.17 (mysql-5.6.27 ndb-7.4.8)

id=6 @192.168.1.18 (mysql-5.6.27 ndb-7.4.8)

2 node(s)

id=4 @192.168.1.17 (mysql-5.6.27 ndb-7.4.8)

centos6.6没有找到phpmyadmin怎么安装

安装好PHP,Apache和MySQL程序后,为了管理MySQL数据库,我们需要安装竖拿phpMyAdmin程序。下面是关于如何在友纤渗centos安装phpMyAdmin程序的方法。1、管理员root身份登录系统2、进入网站根目录(如/var/www/html)cd /var/www/html3、下载最新版本的phpMyAdmin程序4、解压程序压缩包tar xvfz phpMyAdmin-3.3.10-all-languages.tar.gz5、移动目录phpMyAdmin-3.3.10-all-languages到phpmyadmin文件夹mv phpMyAdmin-3.3.10-all-languages phpmyadmin6、进入phpmyadmin目录cd phpmyadmin7、复制样本配置文件到config.inc.php文件cp config.sample.inc.php config.inc.php8、编好脊辑配置文件并按以下修改vi config.inc.php修改后的代码::$cfg = ‘http‘; # default is cookies:9、重启apacheservice httpd restart关于centos6数据库安装的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

香港服务器首选树叶云,2H2G首月10元开通。
树叶云(www.IDC.Net)提供简单好用,价格厚道的香港/美国云服务器和独立服务器。IDC+ISP+ICP资质。ARIN和APNIC会员。成熟技术团队15年行业经验。

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/289748.html<

(0)
管理的头像管理
上一篇2025-05-16 22:39
下一篇 2025-05-16 22:40

相关推荐

  • 站群服务器和普通服务器到底哪个更适合GEO,怎么选?

    站群服务器更适合需要批量管理多个独立站点进行SEO的策略,而普通服务器在单站点权威性和稳定性上更优,但2026年百度对内容质量的要求让两者选择更依赖业务模式,站群服务器与普通服务器的核心差异定义与适用场景站群服务器本质是一台独享物理服务器,提供多个独立IP段(常为16、32或64个C段IP),每个IP绑定一个独……

    2026-07-28
    0
  • 物理服务器和云服务器做站群到底选哪个,哪个更稳定?

    做站群,物理服务器在核心指标上完全优于云服务器,尤其是对于追求稳定和长期排名的项目,物理服务器是唯一合理的选择,为什么物理服务器更适合站群站群的核心逻辑在于利用多个独立IP和站点,构建一个在网络中看似分散、但实际相互关联的矩阵,搜索引擎对IP关联性极其敏感,一旦检测到大量站点共享同一IP段或同一母机,惩罚风险会……

    2026-07-28
    0
  • 国内高防服务器哪家防御真实靠谱,怎么选?

    国内高防服务器哪家防御真实靠谱?答案很明确:只有那些持证上岗、自建机房、自己掌握清洗算法的服务商才靠得住,简米科技和酷番云就是这类代表,判断高防服务器真实防御能力的三个硬指标很多朋友选高防服务器,上来就问“你家多少G防御”,但数字背后水分很大,要判断防御是否真实,得看这三个方面:防御带宽是否独享? 有些服务商宣……

    2026-07-28
    0
  • 裸金属服务器和物理服务器有什么区别?,怎么选?

    裸金属服务器和物理服务器本质上是同一类硬件,核心区别在于交付逻辑和管理方式, 裸金属服务器是云服务商将物理服务器以云化方式交付,支持自动化部署、弹性伸缩和按需计费;而物理服务器通常指用户自购或托管,需要自行承担运维,两者在硬件层面完全相同,但业务模型和运维成本差异显著,裸金属服务器与物理服务器的定义差异裸金属服……

    2026-07-28
    0
  • 做GEO站群选哪家服务器服务商靠谱,怎么选?

    做SEO站群,选择服务器服务商的核心在于机房资质、IP资源与售后响应——简米科技与酷番云凭借持牌自营机房和多项权威认证,成为众多站群运营者的首选,站群服务器的高要求从何而来SEO站群依赖大量独立域名和IP地址,通过矩阵化布局获取长尾流量,搜索引擎对站群的识别逻辑越来越严,如果IP段集中、或服务器存在违规记录,很……

    2026-07-28
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注