centos 7安装mysql5.5和安装 mariadb使用的命令

以前的Linux系统中数据库大部分是mysql,不过自从被sun收购之后,就没用集成在centos这些开源Linux系统中了,那么如果想用的话就需要自己安装了,首先centos7 已经不支持mysql,因为收费了你懂得,所以内部集成了mariadb,而安装mysql的话会和mariadb的文件冲突,所以需要先卸载掉mariadb,以下为卸载mariadb,安装mysql的步骤。

#列出所有被安装的rpm package

rpm -qa | grep mariadb

#卸载

rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64

错误:依赖检测失败:

libmysqlclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要

libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-6.el7.x86_64 需要

#强制卸载,因为没有--nodeps

rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64

#安装mysql5.5.39的rpm包

rpm -ivh /home/liwei/MySQL-server-5.5.39-2.el6.x86_64.rpm

rpm -ivh /home/liwei/MySQL-client-5.5.39-2.el6.x86_64.rpm

#拷贝配置文件

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf,改名为my.cnf作为mysql配置文件。

#修改响应的配置文件

vim /etc/my.cnf

#把mysql的data拷贝到制定的目录

mv /var/lib/mysql /home/mysql/data/

还要注意目录的属主和权限。

MYSQL启动后报:ERROR! The server quit without updating PID file错误的问题解决

1、权限不够:chown -R mysql:mysql /home/mysql/data” “chmod -R 755 /home/mysql/data

2、centos7的selinux问题:打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX

centos7 安装 mariadb 的正确命令

使用的是linode的centos7系统,安装mysql发现已经默认的是mariadb。

但是不管是使用linode官网说明还是百度搜索到的的根本安装方法无法安装成功。

总是提示这一句:

ERROR 2002 (HY000): Can't connect to local Mysql server through socket '/var/lib/mysql/mysql.sock' (2)

最后通过google 搜索 install mariadb on centos 7得到了安装的关键一步。

现在安装成功,特此备注一下整个安装过程:

mysql:[root@localhost ~]# yum -y install mariadb*

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.linode.com

* extras: mirrors.linode.com

* updates: mirrors.linode.com

Resolving Dependencies

--> Running transaction check

---> Package mariadb.x86_64 1:5.5.37-1.el7_0 will be installed

---> Package mariadb-bench.x86_64 1:5.5.37-1.el7_0 will be installed

---> Package mariadb-devel.x86_64 1:5.5.37-1.el7_0 will be installed

---> Package mariadb-embedded.x86_64 1:5.5.37-1.el7_0 will be installed

---> Package mariadb-embedded-devel.x86_64 1:5.5.37-1.el7_0 will be installed

---> Package mariadb-libs.x86_64 1:5.5.37-1.el7_0 will be installed

---> Package mariadb-server.x86_64 1:5.5.37-1.el7_0 will be installed

--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.37-1.el7_0.x86_64

---> Package mariadb-test.x86_64 1:5.5.37-1.el7_0 will be installed

--> Running transaction check

---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

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

Package                           Arch              Version                     Repository          Size

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

Installing:

mariadb                           x86_64            1:5.5.37-1.el7_0            updates            8.9 M

mariadb-bench                     x86_64            1:5.5.37-1.el7_0            updates            385 k

mariadb-devel                     x86_64            1:5.5.37-1.el7_0            updates            744 k

mariadb-embedded                  x86_64            1:5.5.37-1.el7_0            updates            3.6 M

mariadb-embedded-devel            x86_64            1:5.5.37-1.el7_0            updates            7.4 M

mariadb-libs                      x86_64            1:5.5.37-1.el7_0            updates            752 k

mariadb-server                    x86_64            1:5.5.37-1.el7_0            updates             11 M

mariadb-test                      x86_64            1:5.5.37-1.el7_0            updates            7.9 M

Installing for dependencies:

perl-DBD-MySQL                    x86_64            4.023-5.el7                 base               140 k

Transaction Summary

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

Install  8 Packages (+1 Dependent package)

Total download size: 40 M

Installed size: 279 M

Downloading packages:

(1/9): mariadb-bench-5.5.37-1.el7_0.x86_64.rpm                                     | 385 kB  00:00:00

(2/9): mariadb-devel-5.5.37-1.el7_0.x86_64.rpm                                     | 744 kB  00:00:00

(3/9): mariadb-embedded-5.5.37-1.el7_0.x86_64.rpm                                  | 3.6 MB  00:00:00

(4/9): mariadb-5.5.37-1.el7_0.x86_64.rpm                                           | 8.9 MB  00:00:00

(5/9): mariadb-libs-5.5.37-1.el7_0.x86_64.rpm                                      | 752 kB  00:00:00

(6/9): mariadb-server-5.5.37-1.el7_0.x86_64.rpm                                    |  11 MB  00:00:00

(7/9): mariadb-embedded-devel-5.5.37-1.el7_0.x86_64.rpm                            | 7.4 MB  00:00:00

(8/9): mariadb-test-5.5.37-1.el7_0.x86_64.rpm                                      | 7.9 MB  00:00:00

(9/9): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm                                       | 140 kB  00:00:00

----------------------------------------------------------------------------------------------------------

Total                                                                      36 MB/s |  40 MB  00:00:01

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : 1:mariadb-libs-5.5.37-1.el7_0.x86_64                                                   1/9

Installing : 1:mariadb-5.5.37-1.el7_0.x86_64                                                        2/9

Installing : perl-DBD-MySQL-4.023-5.el7.x86_64                                                      3/9

Installing : 1:mariadb-server-5.5.37-1.el7_0.x86_64                                                 4/9

Installing : 1:mariadb-devel-5.5.37-1.el7_0.x86_64                                                  5/9

Installing : 1:mariadb-embedded-5.5.37-1.el7_0.x86_64                                               6/9

Installing : 1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_64                                         7/9

Installing : 1:mariadb-test-5.5.37-1.el7_0.x86_64                                                   8/9

Installing : 1:mariadb-bench-5.5.37-1.el7_0.x86_64                                                  9/9

Verifying  : 1:mariadb-test-5.5.37-1.el7_0.x86_64                                                   1/9

Verifying  : 1:mariadb-embedded-devel-5.5.37-1.el7_0.x86_64                                         2/9

Verifying  : 1:mariadb-embedded-5.5.37-1.el7_0.x86_64                                               3/9

Verifying  : 1:mariadb-libs-5.5.37-1.el7_0.x86_64                                                   4/9

Verifying  : 1:mariadb-bench-5.5.37-1.el7_0.x86_64                                                  5/9

Verifying  : 1:mariadb-5.5.37-1.el7_0.x86_64                                                        6/9

Verifying  : 1:mariadb-server-5.5.37-1.el7_0.x86_64                                                 7/9

Verifying  : perl-DBD-MySQL-4.023-5.el7.x86_64                                                      8/9

Verifying  : 1:mariadb-devel-5.5.37-1.el7_0.x86_64                                                  9/9

Installed:

mariadb.x86_64 1:5.5.37-1.el7_0                        mariadb-bench.x86_64 1:5.5.37-1.el7_0

mariadb-devel.x86_64 1:5.5.37-1.el7_0                  mariadb-embedded.x86_64 1:5.5.37-1.el7_0

mariadb-embedded-devel.x86_64 1:5.5.37-1.el7_0         mariadb-libs.x86_64 1:5.5.37-1.el7_0

mariadb-server.x86_64 1:5.5.37-1.el7_0                 mariadb-test.x86_64 1:5.5.37-1.el7_0

Dependency Installed:

perl-DBD-MySQL.x86_64 0:4.023-5.el7

Complete!

[root@localhost ~]# systemctl start mariadb.service

[root@localhost ~]# systemctl enable mariadb.service

ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.servi

ce'

[root@localhost ~]# mysql

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

Your MariaDB connection id is 2

Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> logout

-> exit

->

-> ;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaD

B server version for the right syntax to use near 'logout

exit' at line 1

MariaDB [(none)]> exit

Bye

[root@localhost ~]# systemctl enable mariadb.service

[root@localhost ~]# mysql

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

Your MariaDB connection id is 3

Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

MariaDB [(none)]> use test

Database changed

MariaDB [test]> show tables;

Empty set (0.00 sec)

MariaDB [test]> exit

Bye

[root@localhost ~]# mysql_secure_installation

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

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

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y

... Success!

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y

... Success!

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y

... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

[root@localhost ~]# mysql -uroot -p

Enter password:

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

Your MariaDB connection id is 15

Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| zbphp.com          |

+--------------------+

4 rows in set (0.00 sec)

MariaDB [(none)]>

(0)

相关推荐

  • Centos7 下mysql重新启动MariaDB篇

    前言 MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险.[3] MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品.在存储引擎方面,10.0.9版起使用XtraDB(名称代号为Aria)来代替MySQL的InnoDB # yum install mysql -y # mysql ERRO

  • CentOS 7下MySQL服务启动失败的快速解决方法

    今天,启动MySQL服务器失败,如下所示: [root@spark01 ~]# /etc/init.d/mysqld start Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe&qu

  • centos6利用yum安装php mysql gd的步骤

    系统:Centos6.0 32位 一.安装mysql #yum -y install mysql mysql-server mysql-devel 配置mysql开机启动服务 #chkconfig --add mysqld (在服务清单中添加mysql服务) #chkconfig mysqld on (设置mysql服务随开机启动) #service mysqld start (启动mysql服务) 二.安装PHP #yum -y install php #service httpd resta

  • 解析centos中Apache、php、mysql 默认安装路径

    apache:如果采用RPM包安装,安装路径应在 /etc/httpd目录下apache配置文件:/etc/httpd/conf/httpd.confApache模块路径:/usr/sbin/apachectlweb目录:/var/www/html如果采用源代码安装,一般默认安装在/usr/local/apache2目录下 php:如果采用RPM包安装,安装路径应在 /etc/目录下php的配置文件:/etc/php.ini如果采用源代码安装,一般默认安装在/usr/local/lib目录下ph

  • 在CentOS上MySQL数据库服务器配置方法

    无意中还找到了CentOS的专业论坛,记住:http://www.centospub.com 于是,开始的学习配置 本次环境: CentOS系统, mysql-server(版本忘了,因为是使用yum安装的) 过程如下(转载,根据本人安装详细要求,略加修改) : 在提到网站构架的时候,我们经常能够看到"LAMP"的说法,它就是"Linux + Apache + MySQL + PHP". MySQL+PHP的协同成功案例已经很多了.比如国外的PHPBB,VBB,国内

  • CentOS 6.4安装配置LNMP服务器(Nginx+PHP+MySQL)

    准备篇 1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙 备注:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败, 正确

  • CentOS+Nginx+PHP+MySQL详细配置(图解)

    一.安装MySQL 目前web服务器已经很少有跑静态页面的,如果要跑动态网站那当然就离不开数据库,虽然在以前文章中有写MySQL是怎么安装的,但是感觉好久没装MySQL,现在只把步骤贴出来,就不做过多的讲解了 #useradd mysql #tar zxvf mysql-5.0.40.tar.gz #cd mysql-5.0.40 #./configure --prefix=/usr/local/mysql #make && make install #/usr/local/mysql/b

  • CentOS 5.5下安装MySQL 5.5全过程分享

    打开终端 切换到根目录 [shell@localhost ~]# su -安装Mysql5.5之前先卸载CentOS自带的Mysql5.0. [root@localhost ~]# yum remove mysql 安装cmake 下载cmake源码包cmake-2.8.5.tar.gz [root@localhost ~]# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz编译安装[root@localhost]# tar xzvf

  • CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)

    准备篇: 1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙 备注:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败, 正

  • Centos7.3下mysql5.7安装配置教程

    本文大家分享了mysql5.7安装配置教程,供大家参考,具体内容如下 第一步:获取mysql YUM源 进入mysql官网获取RPM包下载地址 https://dev.mysql.com/downloads/repo/yum/ 点击 下载 右击 复制链接地址https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 得到这个 这个就是Yum仓库的rpm包 其实就是一个下载地址 第二步:下载和安装mysql源 先下载

随机推荐