删除./mysql/var下的所有数据后,怎么重新安装初始数据库?
(1)进入./mysql/bin目录下,执行脚本./mysql_install_db;
(2)执行完(1)后,此时会在./mysql/var目录下创建两个目录文件mysql、test;
(3)修改mysql、test两个目录及目录下所有文件的权限:chown mysql:mysql -R mysql test,注意这里一定要加上-R参数,否则启动会报错;
(4)进入./mysql/bin启动:./mysqld_safe --user=mysql &
该操作流程中出现过的问题及原因分析:
(1)执行./mysql_install_db报错
Installing MySQL system tables...
100309 17:49:10 [ERROR] /usr/local/mysql/libexec/mysqld: unknown option '--innodb_file_per_table'
100309 17:49:10 [ERROR] Aborting
错误原因:配置文件/etc/my.cnf中添加了参数innodb_file_per_table,而此参数mysql初始安装还不支持,所以报错。
解决方法:将其从配置文件中屏蔽掉即可。
(2)执行./mysql_install_db成功后,启动时报错
100309 17:51:58 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
^G/usr/local/mysql/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
100309 17:51:58 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
100309 17:51:58 [ERROR] /usr/local/mysql/libexec/mysqld: unknown option '--innodb_file_per_table'
100309 17:51:58 [ERROR] Aborting
错误原因:使用perror 13,打印出的错误信息为:OS error code 13: Permission denied。
解决方法:查看安装上的mysql文件权限均为root权限,执行./mysqld_safe --user=mysql &启动命令,显然mysql用户没有权限去读取./mysql/plugin.frm文件,所以要对已经安装上的所有文件权限做调整:chown mysql:mysql -R mysql test.(注意这里一定要加上-R参数,否则目录内的文件权限没有修改,再次启动还会报错的)
(3)启动报错
100309 17:59:33 mysqld_safe mysqld from pid file /usr/local/mysql/var/localhost.localdomain.pid ended
100309 17:59:53 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
100309 17:59:53 [ERROR] Unknown/unsupported table type: innodb
100309 17:59:53 [ERROR] Aborting
错误原因:错误很明显,在当前的数据库中还不支持innodb引擎(我在配置文件中添加了参数--default-storage- engine=innodb)。造成这个问题的主要原因是我在最初编译MySQL数据库时没有将innodb添加进去,所以这里找不到该引擎。
解决方法:先将配置文件中的参数--default-storage-engine参数注释掉,正常启动并登入后执行插入引擎的命令:install plugin innodb soname 'ha_innodb.so';(uninstall plugin innodb)
(4)uninstall plugin innodb后给出warning:Plugin is busy and will be uninstalled on shutdown
在热拔出innodb引擎时 ,mysql会去检查该引擎是否处于使用状态。因为我在存储过程中添加了参数default-storage-engine=innodb,所以给出上述提示。在exit登出系统再登入,执行show engines命令,此时报出如下错误:
mysql> show engines;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> 100309 18:14:21 mysqld_safe Number of processes running now: 0
100309 18:14:21 mysqld_safe mysqld restarted
100309 18:14:21 mysqld_safe mysqld from pid file /usr/local/mysql/var/localhost.localdomain.pid ended
查看错误日志:
00309 18:28:03 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.
key_buffer_size=16777216
read_buffer_size=258048
max_used_connections=1
max_threads=151
threads_connected=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 132701 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
thd: 0x884b968
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0xb3f9f3a4 thread_stack 0x30000
/usr/local/mysql/libexec/mysqld(my_print_stacktrace+0x22) [0x838f1f2]
/usr/local/mysql/libexec/mysqld(handle_segfault+0x37f) [0x81af04f]
[0xb7f23420]
/usr/local/mysql/libexec/mysqld [0x82c49a7]
/usr/local/mysql/libexec/mysqld(plugin_foreach_with_mask(THD*, char (*)(THD*, st_plugin_int*, void*), int, unsigned int, void*)+0xd9) [0x8317a39]
/usr/local/mysql/libexec/mysqld(fill_schema_engines(THD*, TABLE_LIST*, Item*)+0x33) [0x82b8873]
/usr/local/mysql/libexec/mysqld(get_schema_tables_result(JOIN*, enum_schema_table_state)+0x1ce) [0x82b8a8e]
/usr/local/mysql/libexec/mysqld(JOIN::exec()+0x455) [0x822fc35]
/usr/local/mysql/libexec/mysqld(mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*)+0x158) [0x82320d8]
/usr/local/mysql/libexec/mysqld(handle_select(THD*, st_lex*, select_result*, unsigned long)+0x15d) [0x8232a3d]
/usr/local/mysql/libexec/mysqld [0x81ba660]
/usr/local/mysql/libexec/mysqld(mysql_execute_command(THD*)+0x5d40) [0x81c3fd0]
/usr/local/mysql/libexec/mysqld(mysql_parse(THD*, char const*, unsigned int, char const**)+0x208) [0x81c8048]
/usr/local/mysql/libexec/mysqld(dispatch_command(enum_server_command, THD*, char*, unsigned int)+0xd1b) [0x81c8d6b]
/usr/local/mysql/libexec/mysqld(do_command(THD*)+0xe1) [0x81c9781]
/usr/local/mysql/libexec/mysqld(handle_one_connection+0x5be) [0x81b7cce]
/lib/libpthread.so.0 [0xb7ef93cb]
/lib/libc.so.6(clone+0x5e) [0xb7cf0e8e]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x88916d0 = show engines
thd->thread_id=2
thd->killed=NOT_KILLED
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
100309 18:28:03 mysqld_safe Number of processes running now: 0
100309 18:28:03 mysqld_safe mysqld restarted
100309 18:28:04 [ERROR] Unknown/unsupported table type: innodb
100309 18:28:04 [ERROR] Aborting
可以看到这里show engines成为了一个中断信号11,导致Mysqld重启,又由于my.cnf参数问题,最终导致启动失败。(信号11的出现很有可能是配置文件参数错误,经网络搜索好像说明这也是mysql自身的bug)



本文转自 yubowei 51CTO博客,原文链接:http://blog.51cto.com/samyubw/282973

MySQL重新初始化安装数据库的更多相关文章

  1. 【linux】【mysql】CentOS7安装mysql5.6.26

    http://www.cnblogs.com/dreamhome/p/4716425.html     linux系统CentOS7到http://mirrors.sohu.com/mysql/下载想 ...

  2. 源码安装mysql 5.7.19数据库

    1.系统要求yum install -y cmake make gcc gcc-c++ bison  ncurses ncurses-devel 2.创建用户和组groupadd mysql & ...

  3. windows 系统如何安装 mysql 8.0.15 数据库?

    windows 系统如何安装 mysql 8.0.15 数据库? 1. 下载安装包 下载地址:https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0. ...

  4. mysql数据库补充知识1 安装数据库破解数据库密码已经创建用户

    一.安装MYSQL数据库 1.yum安装 #二进制rpm包安装 yum -y install mysql-server mysql 2.源码安装   1.解压tar包 cd /software tar ...

  5. 阿里云安装mysql,初始化密码修改

    阿里云服务器,centos7, rpm包安装MySQL,初始化了个奇葩密码 登陆不上, 修改配置文件/etc/my.cnf,在[mysqld]下面添加一行代码:skip-grant-tables se ...

  6. MySQL 8.0安装以及初始化错误解决方法

    MySQL 8.0 安装配置及错误排查 官网下载 CentOS7环境下的具体安装步骤 初始化MySQL发生错误的解决方法 忘记数据库root密码 官网下载 mysql官网下载链接:https://de ...

  7. 在Fedora 20 上安装Mysql并初始化root密码

    [root@localhost ~]# yum -y install community-mysql-server #安装数据库 已加载插件:langpacks, refresh-packagekit ...

  8. Linux下安装Python3的django并配置mysql作为django默认数据库(转载)

    我的操作系统为centos6.5 1  首先选择django要使用什么数据库.django1.10默认数据库为sqlite3,本人想使用mysql数据库,但为了测试方便顺便要安装一下sqlite开发包 ...

  9. [mysql,2018-02-28] bat安装、启动mysql,并创建数据库、表

    @echo off f: cd F:\mysql-win32 @echo off&setlocal enabledelayedexpansion cd bin echo ###### 停止当前 ...

随机推荐

  1. Shell:Day09.笔记

    awk [单独的编程语言解释器]1.awk介绍 全称:Aho Weinberger Kernaighan 三个人的首字母缩写:  1970年第一次出现在Unix机器上,后来在开源领域使用它: 所以,我 ...

  2. 关于Linux目录的配置

    关于Linux目录的配置说明 大家都知道Linux一切皆文件,但是Linux的文件有那么多,目录也不少.他们都是干什么用的呢,有没有什么规律呢?今天我们就来讨论一下Linux目录的配置 Linux目录 ...

  3. django自定义实现登录验证-更新版

    django自定义实现登录验证 django内置的登录验证必须让开发者使用django内置的User模块,这会让开发者再某些方面被限制住 下面的模块是我自己自定义实现的django验证,使用方式和dj ...

  4. js骚操作骂人不带脏

    前言 很多小伙伴们觉得javaScript很简单,下面的这行 javaScript代码可能会让你怀疑人生. (!(~+[])+{})[--[~+""][+[]]*[~+[]] + ...

  5. Git常用指令整理(Git Cheat Sheet)

    [Toc] 1. 创建 复制一个已创建的仓库:git clone ssh://user@domain.com/repo.git 创建一个新的本地仓库:git init 2. 本地修改 显示工作路径下已 ...

  6. 数据结构和算法(Golang实现)(5)简单入门Golang-接口

    接口 在Golang世界中,有一种叫interface的东西,很是神奇. 一.数据类型 interface{} 如果你事前并不知道变量是哪种数据类型,不知道它是整数还是字符串,但是你还是想要使用它. ...

  7. Redis学习三:Redis高可用之哨兵模式

    申明 本文章首发自本人公众号:壹枝花算不算浪漫,如若转载请标明来源! 感兴趣的小伙伴可关注个人公众号:壹枝花算不算浪漫 22.jpg 前言 Redis 的 Sentinel 系统用于管理多个 Redi ...

  8. 恶劣的网络环境下,Netty是如何处理写事件的?

    更多技术分享可关注我 前言 前面,在Netty在接收完新连接后,默认为何要为其注册读事件,其处理I/O事件的优先级是什么?这篇文章,分析到了Netty处理I/O事件的优先级——读事件优先,写事件仅仅是 ...

  9. D. Ehab the Xorcist

    题意: 略: 感觉被演了一波,这是CFdiv2吗? 算是这个构造题吧. 1 首先我们可以将u进行二进制拆分来考虑.加入u>v那么小与v的那些数在怎么拼接也无法使异或值为u. 比如二进制U=1 0 ...

  10. Maven 命令深度理解

    1.前言 Maven 命令看起来简单,一学即会 .其实,Maven 命令底层是插件的执行过程.了解插件和插件目标才有助于深刻的理解 Maven命令. 2.插件与命令的关系 Maven本质上是一个插件框 ...