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

  1. In order to log into MariaDB to secure it, we'll need the current
  2. password for the root user. If you've just installed MariaDB, and
  3. you haven't set the root password yet, the password will be blank,
  4. so you should just press enter here.
  5.  
  6. Enter current password for root (enter for none):
  7. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

此处可以设置mysql的密码

  1. Setting the root password ensures that nobody can log into the MariaDB
  2. root user without the proper authorisation.
  3.  
  4. Set root password? [Y/n] Y
  5. New password:
  6. Re-enter new password:
  7. Password updated successfully!
  8. Reloading privilege tables..
  9. ... Success!
  10.  
  11. By default, a MariaDB installation has an anonymous user, allowing anyone
  12. to log into MariaDB without having to have a user account created for
  13. them. This is intended only for testing, and to make the installation
  14. go a bit smoother. You should remove them before moving into a
  15. production environment.
  16.  
  17. Remove anonymous users? [Y/n] Y
  18. ... Success!
  19.  
  20. Normally, root should only be allowed to connect from 'localhost'. This
  21. ensures that someone cannot guess at the root password from the network.
  22.  
  23. Disallow root login remotely? [Y/n] n
  24. ... skipping.
  25.  
  26. By default, MariaDB comes with a database named 'test' that anyone can
  27. access. This is also intended only for testing, and should be removed
  28. before moving into a production environment.
  29.  
  30. Remove test database and access to it? [Y/n] Y
  31. - Dropping test database...
  32. ... Success!
  33. - Removing privileges on test database...
  34. ... Success!
  35.  
  36. Reloading the privilege tables will ensure that all changes made so far
  37. will take effect immediately.
  38.  
  39. Reload privilege tables now? [Y/n] Y
  40. ... Success!
  41.  
  42. Cleaning up...
  43.  
  44. All done! If you've completed all of the above steps, your MariaDB
  45. installation should now be secure.
  46.  
  47. 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

根据步骤安装就可以了。

修改mysql的默认字符集 

cat /etc/my.cnf

添加

character-set-server=utf8

default-character-set=utf8

好了,下一步

  1. [root@nicknailo ~]# /usr/bin/mysql -u root -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. 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/,

pm2 start mysql

[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

CentOS7用yum安装MySQL与启动的更多相关文章

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

    安装: CentOS 7的yum源中没有正常安装MySQL的mysql-sever文件,需要去官网上下载(通过安装mysql的yum容器,再通过yum安装mysql) 注:安装前,需要卸载所有的mar ...

  2. centos7 yum安装mysql后启动不起来问题

    [root@localhost ~]# systemctl start mysqld       启动失败 Job for mysqld.service failed because the cont ...

  3. centos7使用yum安装mysql 【转】

    转自:http://blog.csdn.net/eclothy/article/details/52733891 使用: yum install mariadb*    (注意,带星号) 安装好后,启 ...

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

    yum快速安装mysql 新增yum源 rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 查看可用的 ...

  5. centos7通过yum安装MySQL

    一:去官网查看最新安装包 https://dev.mysql.com/downloads/repo/yum/ 二:下载MySQL源安装包 wget http://dev.mysql.com/get/m ...

  6. CentOS7的yum安装mysql

    CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql.com ...

  7. centos7在线yum安装mysql时官方镜像下载过慢的解决方案

    帮客户调试数据库,搭建一测试环境,centos7最小化安装后,在线安装mysql. 步骤: 1. wget -i http://dev.mysql.com/get/mysql57-community- ...

  8. centos7 通过yum安装mysql

    但是CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1.下载mysql的repo源 $ wget http://repo.mysql.co ...

  9. centos7下yum安装mysql

    CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载   # wget http://dev.mysql.com/get/mysql-communit ...

随机推荐

  1. hdoj 1299 Diophantus of Alexandria

    hdoj 1299 Diophantus of Alexandria 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1299 题意:求 1/x + 1/y ...

  2. HDU3524 数论

    Perfect Squares Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  3. C语言预处理

    1.由源码到可执行程序的过程(1)源码.c->(编译)->elf可执行程序(2)源码.c->(编译)->目标文件.o->(链接)->elf可执行程序(3)源码.c- ...

  4. JS日期对象扩展-日期格式化

    日期对象扩展(日期格式化)yyyy-MM-dd hh:mm:ss.S Date.prototype.format = function(fmt) { var o = { "M+" ...

  5. Maven -- 将引用的本地jar文件打进war包里

    我们在做maven项目开发中有时候引用了本地第三方包,例如: <dependency> <groupId>org.artofsolving.jodconverter</g ...

  6. Flash Sort

    FlashSort依然类似桶排,主要改进了对要使用的桶的预测,或者说,减少了无用桶的数量从而节省了空间,例如 待排数字[ 6 2 4 1 5 9 100 ]桶排需要100个桶,而flash sort则 ...

  7. 省队集训Day1 睡觉困难综合征

    传送门:https://www.luogu.org/problem/show?pid=3613 [题解] 按二进制位分开,对于每一位,用“起床困难综合征”的方法贪心做. 写棵LCT,维护正反两种权值, ...

  8. Spring 与 Quartz 动态配置(数漫江湖)

    因为项目的需求,需要有动态配置计划任务的功能.本文在 Quartz JobBean 中获取配置的 Quartz cronExpression 时间表达式及 Spring Bean 的对象名.方法名并运 ...

  9. SQL SERVER 常用公式

    SQL SERVER 获取当前月的天数 SELECT -DAY(getdate()+-DAY(getdate())) SQL server 除法计算百分比[整数乘1.0否则结果为0或1] CONVER ...

  10. VS推荐插件

    以下插件均可在NuGet下载 Smooth Scroll 平滑滚动 Format document on Save 保存时自动格式化代码 Supercharger VS增强插件[破解教程] HideM ...