rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm
报错:
主要是因为CentOS本身自带MariaDB冲突。
yum list | grep mysql
然后yum remove mysql-libs
删掉已经存在的依赖:
再次执行rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm
:
这是因为却少
autoconf
库: yum -y install autoconf
要初始化数据库执行命令:
-
yum -y install autoconf
: 自动加载mysql配置 /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
是对的;
ntsysv
:查看kernel底层开机自启动表, [*] mysql
✅:
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权限