CentOS7用yum安装 MySQL

首先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

#安装mysql依赖
yum install vim libaio net-tools

其他情况:

1、centos下yum暂时没有mysql-server直接安装包;
MariaDB是MySQL社区开发的分支,也是一个增强型的替代品;

2、安装MariaDB
yum -y install mariadb-server mariadb mariadb-devel
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
firewall-cmd --permanent --add-service mysql
systemctl restart firewalld.service
iptables -L -n|grep 3306

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.

Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)

此处可以设置mysql的密码

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] n
 ... skipping.

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!

跟着上面的设置,注意remote login这里设置为n.

1. 下载mysql的repo源

$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2. 安装mysql-community-release-el7-5.noarch.rpm包

$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。

3. 安装mysql

$ sudo yum install mysql-server

根据步骤安装就可以了。

[[email protected] ~]# /usr/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11

输入上面的设置密码

进入mysql客户端之后,show databases;

启动mysql服务:

1、使用 service 启动:service mysqld start
2、使用 mysqld 脚本启动:/etc/inint.d/mysqld start

持久化启动mysql  cd  /usr/bin/,

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff }
span.s1 { }

pm2 start mysql

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #34bc26; background-color: #ffffff }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #828282; background-color: #ffffff }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #33bbc8; background-color: #ffffff }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #cccccc; background-color: #ffffff }
span.s1 { color: #34bc26 }
span.s2 { }
span.s3 { color: #000000 }
span.s4 { color: #828282 }
span.s5 { color: #33bbc8 }
span.s6 { color: #ffffff; background-color: #000000 }

[PM2] Starting /usr/bin/mysql in fork_mode (1 instance)

[PM2] Done.

┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬──────┬──────────┐

App name id mode pid   status restart uptime cpu mem       user watching

├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼──────┼──────────┤

app      │ 1  │ fork │ 2330  │ online │ 0       │ 95m    │ 0%  │ 37.3 MB   │ root │ disabled │

app      │ 3  │ fork │ 3498  │ online │ 0       │ 82m    │ 0%  │ 25.2 MB   │ root │ disabled │

mongo    │ 0  │ fork │ 2104  │ online │ 0       │ 104m   │ 0%  │ 11.5 MB   │ root │ disabled │

mysql    │ 5  │ fork │ 11449 │ online │ 0       │ 0s     │ 0%  │ 2.0 MB    │ root │ disabled │

└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────┴───────────┴──────┴──────────┘

 Use `pm2 show <id|name>` to get more details about an app

原文地址:https://www.cnblogs.com/nicknailo/p/8571152.html

时间: 2024-10-05 05:32:20

CentOS7用yum安装 MySQL的相关文章

centos7通过yum安装mysql,并授权远程连接

安装: CentOS 7的yum源中没有正常安装MySQL的mysql-sever文件,需要去官网上下载(通过安装mysql的yum容器,再通过yum安装mysql) 注:安装前,需要卸载所有的mariadb软件(完全兼容mysql的另一个数据库,mysql原创者所写),通过命令yum remove mariadb* 获取yum地址: 安装mysql的yum容器: 其实就是在/etc/yum.repo.d/  下添加了两个容器档案: 查看那个yum容器有什么mysql软件(yum install

Centos7下yum安装mysql

Centos7 yum源没有Mysql,要到官网下载. 单击此处下载 下载完RPM安装 yum安装Mysqld 启动Mysqld 初次安装root没有密码 设置密码 #mysql -uroot mysql>set password for 'root'@'localhost'=password('密码'); mysql>exit

CentOS7的yum安装mysql

CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 2. 安装mysql-community-release-el7-5.noarch.rpm包 $ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm 安装这个

centos7利用yum安装mysql 8.0.12

清理原有的mysql rpm -qa | grep mysql #可能的显示情况如下 #mysql-community-libs-8.0.12-1.el7.x86_64 #mysql80-community-release-el7-1.noarch #mysql-community-client-8.0.12-1.el7.x86_64 #mysql-community-common-8.0.12-1.el7.x86_64 #mysql-community-server-8.0.12-1.el7.

centos7 用yum安装mysql(转)

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载 # wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server 成功安装之后重启mysql服务 # service mysqld res

centos7下yum安装mysql(转)

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载   # wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server 成功安装之后重启mysql服务   # service mysqld

[转]centos7下yum安装mysql

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载 # wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server 成功安装之后重启mysql服务 # service mysqld res

阿里云centos7使用yum安装mysql的正确姿势

yum快速安装mysql 新增yum源 rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 查看可用的mysql版本(直接略过) yum repolist enabled | grep "mysql.*-community.*" 导入 yum -y install mysql-community-server 加入开机启动 systemctl enable mysqld 启动mysql s

centos7通过yum安装MySQL

一:去官网查看最新安装包 https://dev.mysql.com/downloads/repo/yum/ 二:下载MySQL源安装包 wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 安装MySql源 yum -y install mysql57-community-release-el7-11.noarch.rpm 查看一下安装效果 yum repolist enabled | grep my