Centos7.4 安装mysql 8.0.13

mysql wangleiadmin 361℃ 0评论

1.查看系统版本

[root@nuanfeng ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

2.下载mysql repo源

下载地址:https://dev.mysql.com/downloads/repo/yum/
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

3.安装yum 源及缓存

rpm -ivh mysql80-community-release-el7-1.noarch.rpm
#执行后会在/etc/yum.repos.d/目录下生成mysql-community.repo mysql-community-source.repo
yum clean all
yum makecache

4.yum 安装mysql

yum install mysql-community-server -y

5.启动mysql服务

systemctl start mysqld.service

6.获取mysql初始密码

cat /var/log/mysqld.log |grep password

7.修改初始密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'passowrd';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';  #为了适应sqlyog 或者 navicat 登录

8.设置mysql远程登录

use mysql;
select host,user,authentication_string,plugin from user;
update user set host='%' where user='root';

9.数据库表不区分大小写

vim /etc/my.cnf    #文件末尾加入 lower_case_table_names=1
#注意,如果数据库之前已经有数据了,即已经创建了数据库和表,那么需要把这些数据全部清空掉.否则会造成数据库无法启动。
报错信息:
[root@nuanfeng ~]# systemctl restart mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
查看mysql日志
cat /var/log/mysqld.log

2019-01-03T09:35:06.883160Z 1 [ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('1') and data dictionary ('0').
解决方法:
删除 MySQL的数据 rm -rf /var/lib/mysql
初始化数据库并加入 lower-case-table-names=1
/usr/sbin/mysqld --initialize --user=mysql --lower-case-table-names=1

然后重新启动mysql:systemctl restart mysqld.service

10.mysql设置开机启动

systemctl enable mysqld.service

转载请注明:暖风 » Centos7.4 安装mysql 8.0.13

喜欢 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址