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? http://dev.mysql.com/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=http://repo.mysql.com/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.2020-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六2016-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 http://shop.mysql.com
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/my.cnf 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, 2016, 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...
總結
以上是生活随笔為你收集整理的linux7yum安装mysql,CentOS7 使用yum安装mysql的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python并发处理list数据_3种方
- 下一篇: html调用父页面的函数,javascr