300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > linux7yum安装mysql CentOS7 使用yum安装mysql

linux7yum安装mysql CentOS7 使用yum安装mysql

时间:2024-05-21 09:20:37

相关推荐

linux7yum安装mysql CentOS7 使用yum安装mysql

1、安装libaio,

yum install libaio

2、卸载mariadb

yum remove mariadb-libs-5.5.41-2.el7_0.x86_64

3、下载mysql yumrepository

wget /get/mysql-community-release-el7-5.noarch.rpm

4、添加Mysql yumrepository到系统列表的中,执行

yum localinstall mysql-community-release-el7-5.noarch.rpm

5、查看yum源中的版本

yum repolist all | grep mysql

mysql-connectors-community/x86_64 MySQLConnectors Community启用: 24

mysql-connectors-community-source MySQLConnectors Community - Sourc禁用

mysql-tools-community/x86_64 MySQL Tools Community启用: 38

mysql-tools-community-source MySQL Tools Community - Source禁用

mysql55-community/x86_64 MySQL 5.5 Community Server禁用

mysql55-community-source MySQL 5.5 Community Server - Sourc禁用

mysql56-community/x86_64 MySQL 5.6 Community Server启用: 289

mysql56-community-source MySQL 5.6 Community Server - Sourc禁用

mysql57-community-dmr/x86_64 MySQL 5.7 Community Server Develop禁用

mysql57-community-dmr-source MySQL 5.7 Community Server Develop禁用

6、可以通过修改/etc/yum.repos.d/mysql-community.repo文件来决定启用哪个版本,例如启用下面的版本

# Enable to use MySQL 5.6

[mysql56-community]

name=MySQL 5.6 Community Server

baseurl=/yum/mysql-5.6-community/el/7/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

7、查看启用的哪个版本

yum repolist enabled | grep mysql

mysql-connectors-community/x86_64 MySQL Connectors Community 24

mysql-tools-community/x86_64 MySQL Tools Community 38

mysql56-community/x86_64 MySQL 5.6 CommunityServer 289

8、安装mysql,执行下面的命令

yum install mysql-community-server

需要安装下图所示的包

依赖关系解决

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

Package架构版本源大小

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

正在安装:

mysql-community-server x86_64 5.6.34-2.el7 mysql56-community 59 M

为依赖而安装:

mysql-community-client x86_64 5.6.34-2.el7 mysql56-community 19 M

mysql-community-common x86_64 5.6.34-2.el7 mysql56-community 257 k

mysql-community-libs x86_64 5.6.34-2.el7 mysql56-community 2.0 M

perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k

perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k

perl-DBI x86_64 1.627-4.el7 base 802 k

perl-IO-Compress noarch 2.061-2.el7 base 260 k

perl-Net-Daemon noarch 0.48-5.el7 base 51 k

perl-PlRPC noarch 0.-14.el7 base 36 k

9、启动mysql

systemctl start mysqld

10、查看mysql状态

systemctl status mysqld

mysqld.service - MySQL Community Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)

Active: active (running) since六-10-29 03:57:59CST; 56s ago

Process: 4549 ExecStartPost=/usr/bin/mysql-systemd-start post(code=exited, status=0/SUCCESS)

Process: 4489 ExecStartPre=/usr/bin/mysql-systemd-start pre(code=exited, status=0/SUCCESS)

MainPID: 4548 (mysqld_safe)

CGroup: /system.slice/mysqld.service

├─4548 /bin/sh /usr/bin/mysqld_safe

└─4701 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql--plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mys...

10月29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Support MySQL by buyingsupport/licenses at

10月29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Note: new default config filenot created.

10月29 03:57:57localhost.localdomain mysql-systemd-start[4489]: Please make sure your configfile is current

10月29 03:57:57localhost.localdomain mysql-systemd-start[4489]: WARNING: Default config file/etc/f exists on the system

10月29 03:57:57localhost.localdomain mysql-systemd-start[4489]: This file will be read bydefault by the MySQL server

10月29 03:57:57localhost.localdomain mysql-systemd-start[4489]: If you do not want to usethis, either remove it, or use the

10月29 03:57:57localhost.localdomain mysql-systemd-start[4489]: --defaults-file argument tomysqld_safe when starting the server

10月29 03:57:57localhost.localdomain mysqld_safe[4548]: 161029 03:57:57 mysqld_safe Logging to'/var/log/mysqld.log'.

10月29 03:57:58 localhost.localdomainmysqld_safe[4548]: 161029 03:57:58 mysqld_safe Starting mysqld daemon withdatabases from /...mysql

10月29 03:57:59localhost.localdomain systemd[1]: Started MySQL Community Server.

Hint: Some lines were ellipsized, use -l toshow in full.

11、测试安装是否成功

mysql可以正常的登入

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

Your MySQL connection id is 2

Server version: 5.6.34 MySQL CommunityServer (GPL)

Copyright (c) 2000, , Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

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

mysql>

12、关闭firewall,禁止firewall开机启动

systemctl stop firewalld.service

systemctl disable firewalld.service

13、安装iptables防火墙,并启用iptables

yum install iptables-services

service iptables start

14、mysql 安全设置

执行mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FORALL MySQL

SERVERS INPRODUCTION USE! PLEASE READ EACH STEPCAREFULLY!

In order to log into MySQL to secure it, we'll need thecurrent

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

you haven't set the root password yet, the password will beblank,

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)

Enter current password for root (enter for none):

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 intothe MySQL

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 MySQL installation has an anonymous user,allowing anyone

to log into MySQL without having to have a user accountcreated for

them. This isintended 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 fromthe network.

Disallow root login remotely? [Y/n] n

... skipping.

By default, MySQL comes with a database named 'test' thatanyone can

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

before moving into a production environment.

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

- Dropping testdatabase...

ERROR 1008 (HY000) at line 1: Can't drop database 'test';database doesn't exist

... Failed! Not critical, keep moving...

- Removingprivileges on test database...

... Success!

Reloading the privilege tables will ensure that all changesmade so far

will take effect immediately.

Reload privilege tables now? [Y/n] y

... Success!

All done! If you'vecompleted all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

Cleaning up...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。