MySQL 8.0安装

2021/6/15 19:21:55

本文主要是介绍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安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程