MySQL 8.0安装

1.配置yum包

yum search libaio
yum install -y libaio

2.清理原环境

rpm -qa|grep -i mariadb*
yum remove -y mariadb*

3.创建用户

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

4.解压,创建目录

cd /mysql_dir/
tar xvf mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz
ln -s mysql-8.0.23-linux-glibc2.12-x86_64 mysql
cd ..
mkdir data
chown mysql:mysql data
chmod 750 data

5.配置环境变量

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/mysql_dir/mysq8/mysql/bin ===>修改

export PATH

6.配置文件

cd /mysql_dir/mysql
vi /etc/my.cnf

[mysqld]
server-id=8
datadir=/mysql_dir/data
socket=/tmp/mysql.sock
user=mysql
log-bin=/mysql_dir/data/mysql-bin.log
log-bin-index=/mysql_dir/data/mysql-bin.index

[mysqld_safe]
log-error=/mysql_dir/data/mysqld.log
pid-file=/mysql_dir/data/mysqld.pid

[mysql]
prompt="\\u@\\h:\\p [\\d]>"

7.初始化(这个过程,会生成mysql的系统文件和临时密码,需要使用该密码登录,修改密码)

mysqld --initialize --user=mysql

8.启动mysql,并登陆修改密码

mysqld_safe --user=mysql &
alter user root@localhost identified by mysql123;
mysql -uroot -pmysql123

 

追加:用户密码添加至配置文件,可以实现免密登录

[client]
host=localhost
user=root
password=mysql123

MySQL 8.0安装

上一篇:MongoDB 复制集机制及原理


下一篇:mysql 数据库设计