检查是否有mariadb
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-server
安装mysql-8.0.31-el7-x86_64.tar.gz包
安装mysql-8.0.31-el7-x86_64.tar.gz包
cd data
tar -xvf mysql-8.0.31-el7-x86_64.tar.gz
mv mysql-8.0.31-el7-x86_64 mysql
依赖安装
报错解决,安装依赖 yum install -y libaio
还有报错,安装依赖 yum -y install numactl
修改mysql配置
vi /etc/my.cnf 覆盖以下全部内容,注意格式
[client]
port=3306
socket=/data/tmp/mysql/mysql.sock
[mysqld]
port=3306
user=mysql
socket=/data/tmp/mysql/mysql.sock
basedir=/data/mysql
datadir=/data/mysql/data
log-error=error.log
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections = 4096
transaction_isolation = READ-COMMITTED
character-set-server = utf8mb4
#collation-server = utf8mb4_general_ci
collation-server = utf8mb4_bin
lower_case_table_names = 1
#生产环境注释
skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/data/tmp/mysql/log/mysqld.log
pid-file=/data/tmp/mysql/run/mysqld/mysqld.pid
#log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
#my.ini配置文件中更改允许的最大错误连接数
max_connect_errors = 8000
初始化mysql配置
groupadd mysql
$> useradd -r -g mysql -s /bin/false mysql
$> mkdir -p /data/tmp/mysql/log
$> touch /data/tmp/mysql/log/mysqld.log
$> chown -R mysql:mysql /data/tmp/mysql
$> chown -R mysql:mysql /data/mysql
$> chmod -R 755 /data/tmp/mysql /data/mysql
$> cd /usr/local
$> tar xvf mysql-8.0.31-el7-x86_64.tar.gz
$> mv mysql-8.0.31-el7-x86_64.tar.gz mysql
$> cd mysql
$> bin/mysqld --initialize --user=mysql
$> bin/mysql_ssl_rsa_setup
# Next command is optional
$> cp support-files/mysql.server /etc/init.d/mysql.server
/etc/init.d/mysql.server start
快捷链接
修改/etc/profile文件
export PATH=${PATH}:/data/mysql/bin
修改密码
$> mysql
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
注释掉/etc/my.cnf文件的skip-grant-tables文章来源:https://www.toymoban.com/news/detail-655105.html
修改host域及密码修改
/etc/init.d/mysql.server restart
mysql -u root -p (密码登陆)
alter user 'root'@'localhost' identified by '123456';
use mysql;
update user set host='%' where user='root';
flush privileges;
root忘记密码
开启skip-grant-tables
同上面的修改密码一样,不过得知道host域文章来源地址https://www.toymoban.com/news/detail-655105.html
mysql> ALTER USER 'root'@'%' IDENTIFIED BY 'MyNewPass';
到了这里,关于centos安装mysql8的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!