https://www.cnblogs.com/wangwangfei/p/13717651.html
下载
mysql-8.0.27-el7-x86_64.tar.gz 解压,改名
创建data目录 mkdir /usr/local/mysql/mysql-8/data
创建log目录 mkdir /usr/local/mysql/mysql-8/log
创建log文件 touch /usr/local/mysql/mysql-8/log/mysqld.log
创建用户
groupadd mysql
useradd -r -g mysql mysql
修改文件所属
chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql
初始化
./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/mysql-8/data --initialize
随机密码需要记下来
配置文件修改:/etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/mysql-8/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
user=mysql
port=3306
character-set-server=utf8
注释掉 skip-grant-tables
symbolic-links=0
sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
启动服务
cd到support-files
sh mysql.server start
如果起不来的话,注意报错,注意给mysql相关目录chmod 777 -R权限
配置环境变量
export PATH=$PATH:/usr/local/mysql/bin
访问数据库,使用前面生成的随机密码
mysql -u root -p
缺少libncurses.so.5的话:
cp /lib64/libncurses.so.6 /lib64/libncurses.so.5
cp /lib64/libtinfo.so.6 /lib64/libtinfo.so.5
以下sql命令都需要注意’ “ 符号是否正确
修改默认密码
alter user ‘root’@‘localhost’ identified by ‘123456’;
flush privileges;
允许其他人访问
select user,host from mysql.user;
update mysql.user set host = “%” where user = “root”;
开机自启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start
mysql的一些报错:
1.
[InnoDB] Upgrade is not supported after a crash or shutdown with innodb_fast_shutdown = 2. This redo log was created with MySQL 5.7.28, and it appears logically non empty. Please follow the instructions at http://dev.mysql.com/doc/refman/8.0/en/upgrading.html
升级mysql导致
原因:ib_logfile 文件冲突引起的
解决方法:
进入data目录下将ib_logfile0、ib_logfile1…文件删除即可
2.
Neither found #innodb_redo subdirectory, nor ib_logfile* files
在my.cnf里指定一下日志存放目录
mkdir #innodb_redo
chown -R mysql:mysql #innodb_redo
编辑 etc/my.cnf
[mysqld]
innodb_log_group_home_dir=/var/lib/mysql/redo_log/#innodb_redo