Centos7 上安装mysql遇上的问题:mysql无法正常启动
第一次在Centos上安装mysql遇到的一些问题。
第一步就遇到问题,安装mysql-server报错没有可用包。
【解决方法】
先要安装mysql
# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
- 1
- 2
之后再安装mysql-server
# yum -y install mysql-server
- 1
然后systemctl enable mysqld
设置mysql自启动 之后systemctl start mysqld
这时候出问题了,运行之后一直卡着没有反应,如下
[root@localhost ~]# systemctl start mysqld
Redirecting to /bin/systemctl start mysql.service
- 1
- 2
systemctl status mysqld
查看mysql服务的状态如下
[root@localhost sbin]# systemctl status mysqld
● mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: activating (start-post) since 一 2017-05-15 17:04:12 CST; 5min ago
Process: 981 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
Process: 938 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 981 (code=exited, status=0/SUCCESS); : 982 (mysql-systemd-s)
CGroup: /system.slice/mysqld.service
└─control
├─ 982 /bin/bash /usr/bin/mysql-systemd-start post
└─2315 sleep 1
5月 15 17:04:12 localhost.localdomain systemd[1]: Starting MySQL Community Server...
5月 15 17:04:15 localhost.localdomain mysqld_safe[981]: 170515 17:04:15 mysqld_safe Logging to '/var/lo...g'.
5月 15 17:04:15 localhost.localdomain mysqld_safe[981]: 170515 17:04:15 mysqld_safe Starting mysqld dae...sql
Hint: Some lines were ellipsized, use -l to show in full.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
看不出问题,查看mysql的日志终于找到问题vim /var/log/mysqld.log
2017-05-14 16:40:16 0 [Note] Binlog end
170514 16:40:16 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
170515 17:04:15 mysqld_safe Logging to '/var/log/mysqld.log'.
170515 17:04:15 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2017-05-15 17:04:18 0 [ERROR] /usr/sbin/mysqld: ambiguous option '--character-set=utf8' (character-set-client-handshake, character_sets_dir)
2017-05-15 17:04:18 0 [ERROR] Aborting
- 1
- 2
- 3
- 4
- 5
- 6
原来是my.cnf文件中设置默认字符编码我写成character-set=ut8
而centos7版本中应该设置为default-character-set=utf8
之后继续启动mysql仍然无法启动,查看日志如下
2017-05-15 17:14:21 1195 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2017-05-15 17:14:21 1195 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
2017-05-15 17:14:21 1195 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2017-05-15 17:14:21 1195 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-05-15 17:14:21 1195 [Note] InnoDB: The InnoDB memory heap is disabled
2017-05-15 17:14:21 1195 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-05-15 17:14:21 1195 [Note] InnoDB: Memory barrier is not used
2017-05-15 17:14:21 1195 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-05-15 17:14:21 1195 [Note] InnoDB: Using Linux native AIO
2017-05-15 17:14:21 1195 [Note] InnoDB: Not using CPU crc32 instructions
2017-05-15 17:14:21 1195 [Note] InnoDB: Initializing buffer pool, size = 128.0M
170515 17:04:18 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
注意ERROR
Can’t open the mysql.plugin table. Please run mysql_upgrade to create it.
【解决方法】
在运行初始化权限表的时候使用增加参数–datadir
mysql_install_db –user=mysql –datadir=/usr/local/mysql/var
百度后
安装完mysql server时,一般要执行这个脚本对数据库初始化。 运行这个脚本,会初始化mysql的data目录,并且创建那些系统表。
同样也会初始化系统表空间并且关联innodb表与数据结构。
更多的相关可以点击这里查看
之后启动服务依然卡住,回看前面执行命令之后的提示
Alternatively you can run:
/usr/bin/mysql_secure_installation
- 1
- 2
即执行MySQL安全配置向导mysql_secure_installation
安装完mysql-server 会提示可以运行mysql_secure_installation。运行mysql_secure_installation会执行几个设置:
a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效
执行之后systemctl restart mysqld
命令可以正常执行了
可以正常启动登录mysql
Centos7 上安装mysql遇上的问题:mysql无法正常启动的更多相关文章
- linux 上安装多个不同版本的mysql 踩的坑
最近由于业务需要,考虑使用json类型,据了解 mysql 在版本5.7中可以支持 json 类型的数据支持,但同时目前开发环境中使用的是 mysql 5.6版本,上面还有很多项目的数据库在上面,同时 ...
- 在Linux - Centos上安装Python3(上)
必看内容 在Linux上安装Python常用的2种方法 1.Python源码编译安装,有点复杂,适合老司机 2.从EPEL/IUS仓库安装,新手建议使用些方法,比较简单,目前2019-07-31提供最 ...
- centos7.5安装java JDK、tomcat、mysql
参考资料: https://www.cnblogs.com/sxdcgaq8080/p/7492426.html https://blog.csdn.net/ds986619036/article/d ...
- 当mysql遇上PHP
博客提纲 利用PHP连接mySQL数据库 两套接口:面向对象和面向过程 实现写改删查(CUBD)实例 通过prepare语句处理相同类型的不同SQL语句 通过bind_param()绑定参数,及相关注 ...
- 【PHP】当mysql遇上PHP
博客提纲 利用PHP连接mySQL数据库 两套接口:面向对象和面向过程 实现写改删查(CUBD)实例 通过prepare语句处理相同类型的不同SQL语句 通过bind_param()绑定参数,及相关注 ...
- 在windows上安装不同(两个)版本的Mysql数据库
1.起因: 需要导入一个sql文件,发现死活导不进去.当执行到这一句时,就有问题.经过一番搜索,原来是我的数据库版本(原先Mysql版本5.5)低了,而支持该语句的版本应该是至少要5.7.那我索性就去 ...
- centos7上安装mysql8(上)
1.删除系统现存的mysql rpm -pa | grep mysql 2.卸载mysql组件 yum remove mysql-xxx-xxx- 3.删除mysql的配置文件,卸载不会自动删除配置文 ...
- 在CentOS上安装Nginx配置HTTPS并设置系统服务和开机启动(最全教程)
友情提示:全部配完大约需要20分钟,本教程配合 xshell 和 xftp 使用更佳. 系统配置:CentOS 7.5 本教程 摘繁华 版权所有. 操作按键 常用按键: 复制操作:Shift+Ins ...
- centos7编译安装redis遇坑
编译redis时:make cc Command not found 原因分析:没有安装gcc,执行: yum install gcc 编译redis时:error: jemalloc/jemallo ...
随机推荐
- js操作元素透明度以及浏览器兼容性
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- ORACLE 字符串补零
标准函数Lpad 可以实现左补零,但是如果多于需要长度,则会截断字符串.如下:-----------------------情况一:需要补零. SELECT LPAD ('1234' , ...
- SQL函数-汉字首字母查询
汉字首字母查询处理用户定义函数 CREATE FUNCTION f_GetPY1(@str nvarchar(4000))RETURNS nvarchar(4000)ASBEGIN DECLARE @ ...
- 呼啦圈(keyframes和transform结合)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 如何让不同浏览器调用不同的CSS样式
如何让不同浏览器调用不同的CSS样式 由 于对W3C标准支持程度的不同,往往导致同一个CSS样式表在各种Web浏览器中的呈现大相径庭.以目前市场占有率最高的两个浏览器Microsoft Interne ...
- HTML <section> 标签
实例 文档中的区段,解释了 PRC: <section> <h1>PRC</h1> <p>The People's Republic of Ch ...
- 模式匹配第四弹:if case,guard case,for case
2016-06-06 7388 作者:Olivier Halligon,原文链接,原文日期:2016-05-16 译者:walkingway:校对:Cee:定稿:numbbbbb 现在我们来重新回顾下 ...
- MFC_1.2 消息映射宏 数据绑定和交换
消息映射宏 有三个主要的宏 类内声明 DECLARE_MESSAGE_MAP 表示使用消息映射 在CPP文件中使用 BEGIN_MESSAGE_MAP 和 END_MESSAGE_MAP 包含对应的消 ...
- 诊断:ORA-01919: role ‘PLUSTRACE’ does not exist
如下错误 SQL> grant plustrace to scott; grant plustrace to scott * ERROR at line 1: ORA-01919: role ' ...
- [Algorithm] 3. Digit Counts
Description Count the number of k's between 0 and n. k can be 0 - 9. Example if n = 12, k = 1 in [0, ...