rpm -ivh MySQL-server各种报错以及完整安装说明

rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm报错:

rpm-db-err.png

主要是因为CentOS本身自带MariaDB冲突。

yum list | grep mysql然后yum remove mysql-libs删掉已经存在的依赖:

yum-remove.png

comp.png

再次执行rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm:

err-autoconf.png

这是因为却少autoconf库: yum -y install autoconf

要初始化数据库执行命令:

  1. yum -y install autoconf: 自动加载mysql配置
  2. /usr/bin/mysql_install_db --user=mysql

如果不执行/usr/bin/mysql_install_db --user=mysql:
错误: Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/hadoop100.pid).
less /var/lib/mysql/hadoop100.err:

200522 09:34:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2020-05-22 09:34:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-22 09:34:03 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24) starting as process 79709 ...
2020-05-22 09:34:03 79709 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
2020-05-22 09:34:03 79709 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2020-05-22 09:34:03 79709 [Note] InnoDB: Using atomics to ref count buffer pool pages
2020-05-22 09:34:03 79709 [Note] InnoDB: The InnoDB memory heap is disabled
2020-05-22 09:34:03 79709 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-22 09:34:03 79709 [Note] InnoDB: Memory barrier is not used
2020-05-22 09:34:03 79709 [Note] InnoDB: Compressed tables use zlib 1.2.3
2020-05-22 09:34:03 79709 [Note] InnoDB: Using Linux native AIO
2020-05-22 09:34:03 79709 [Note] InnoDB: Using CPU crc32 instructions
2020-05-22 09:34:03 79709 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2020-05-22 09:34:03 79709 [Note] InnoDB: Completed initialization of buffer pool
2020-05-22 09:34:03 79709 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2020-05-22 09:34:03 79709 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2020-05-22 09:34:03 79709 [Note] InnoDB: Database physically writes the file full: wait...
2020-05-22 09:34:03 79709 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2020-05-22 09:34:04 79709 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2020-05-22 09:34:04 79709 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2020-05-22 09:34:04 79709 [Warning] InnoDB: New log files created, LSN=45781
2020-05-22 09:34:04 79709 [Note] InnoDB: Doublewrite buffer not found: creating new
2020-05-22 09:34:04 79709 [Note] InnoDB: Doublewrite buffer created
2020-05-22 09:34:04 79709 [Note] InnoDB: 128 rollback segment(s) are active.
2020-05-22 09:34:04 79709 [Warning] InnoDB: Creating foreign key constraint system table

主要是/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist: 因为Table 'mysql.plugin' doesn't exist. 而mysql.plugin不存在的原因是, 新安装的mysql服务后,一般需要执行数据库初始化操作 ,从而生成与权限相关的表,但是没有,所以cat /root/.mysql_secret也没有。

所以必须执行 /usr/bin/mysql_install_db --user=mysql

最后再: service mysql start:

Starting MySQL. SUCCESS! 

此时如果cat /root/.mysql_secret有,那么就是随机生成的密码,如果没有就是免密登录。

然后rpm解压MySQL-client就可以用了

/usr/bin/mysqladmin -u root password 123456设置密码123456

事实上我在生产中从来不关服务器上的mysql, 不过一个月周五晚上DevOps检查一次还是会关,设置mysql自启动: chkconfig mysql on;

0, 1, 6是非正常启动,所以这个inittab是对的;

on

ntsysv:查看kernel底层开机自启动表, [*] mysql✅:

ntsysv.png

mysql路径:

路径 内容
/var/lib/mysql mysql数据库文件
/usr/share/mysql 配置文件
/usr/bin 相关命令
/etc/init.d/mysql 启停脚本(sbin)

创建表如果出现:ERROR 1044(42000): Access denied for user ''@'localhost' to database ‘mytestsql’, 是因为是从user登录的不是root, user用户只有usage权限没有create权限

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容