CentOS 6.5 下安装配置 mysql

CentOS 6.5 下安装配置 mysql

使用yum安装,具体过程参见最下边的参考文章。html

安装以后启动失败:mysql

[root@localhost ~]# service mysqld start
Starting mysqld:                                           [  FAILD  ]

启动失败,查看出错缘由(记录在/var/log/mysqld.log 文件里):sql

[root@localhost ~]# cat /var/log/mysqld.log
190425 13:56:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist
190425 13:56:00 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
190425 13:56:00  InnoDB: Initializing buffer pool, size = 8.0M
190425 13:56:00  InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
190425 13:56:00 [ERROR] Plugin 'InnoDB' init function returned error.
190425 13:56:00 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
190425 13:56:00 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
190425 13:56:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

190425 13:58:07 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
190425 13:58:07  InnoDB: Initializing buffer pool, size = 8.0M
190425 13:58:07  InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
190425 13:58:07 [ERROR] Plugin 'InnoDB' init function returned error.
190425 13:58:07 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
190425 13:58:07 [Note] Event Scheduler: Loaded 0 events
190425 13:58:07 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.73'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution

# 注意!(这里的提示是解决以后的,刚安装完mysql时启动是报错的,OK那里是FAILD)
# 这里的提示最后几行是解决以后启动了软件而后端口开放了。与前边报错显示在同一文件里了。)

mysql报错 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist数据库

解决方法:

mysql_install_db (参考自文章2。)后端

# mysql默认不推荐用root用户来启动软件。正常状况下用root启动会有提示或报错,这里没有报错就启动了。须要注意一下。
[root@localhost ~]# service mysqld start
Starting mysqld:                                           [  OK  ]

mysqladmin 设置用户名初始密码报错you need the SUPER privilege for this operation

CREATE USER 'root'@'localhost' IDENTIFIED BY '[这里替换成想要设置的密码]';
GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'root'@'localhost';
GRANT ALL ON *.* TO 'root'@'localhost';

配置root远程访问

# 说明:mysql对用户访问的控制比较完善,同一个用户名从不一样的机器访问同一数据库权限也是不一样的。
# 以root为例。同一个用户root对应mysql数据库中user表里的多行数据。从本地访问时user表里对应host为localhost的一行。
# 即便user表里有一行的host叫作localhost.localdomain也不能从本地访问。(经验如此,具体缘由不详)
# 从远程访问时须要配置user表里对应host为%的一行。

Enter password: *******
select user,host from user;
update user set host='%' where user='root';
flush privileges;

参考资料:

一、Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置dom

二、mysql报错Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't existsocket

相关文章
相关标签/搜索