centos7二进制安装mysql8以及mysql8的新特性

环境说明:
centos7.6
mysql安装版本:
mysql-8.0.17

安装:

cd /usr/local/src/

#下载地址,mysql8好像没有tar.gz换成了tar.xz
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz

#解压
xd -d mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
tar -xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar

mv mysql-8.0.17-linux-glibc2.12-x86_64 /usr/local/mysql-8/
cd /usr/local/mysql-8/

#创建目录和用户
mkdir /data/mysql8
chown  -R  mysql:mysql /data/mysql8
useradd -r -s /bin/false mysql

#初始化,mysql8会生成一个随机密码,一定要记下来
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql-8/ --datadir=/data/mysql8/

编辑配置文件:

vim my.cnf
#内容
[mysqld]
datadir=/data/mysql8
socket=/tmp/mysql8.sock
port=3306
user=mysql
default_authentication_plugin=mysql_native_password
[mysqld_safe]
log-error=/var/log/mariadb/mysql8.log
pid-file=/var/run/mariadb/mysql8.pid
!includedir /etc/my.cnf.d

生成日志文件和目录:

mkdir /var/log/mariadb/
touch /var/log/mariadb/mysql8.log
chown mysql:mysql -R /var/log/mariadb/

配置环境变量:

echo "export PATH=$PATH:/usr/local/mysql-8/bin"  >>  /etc/profile
source /etc/profile

制作启动文件:

cp support-files/mysql.server /etc/init.d/mysqld8
vim /etc/init.d/mysqld8
#修改
basedir=/usr/local/mysql-8
datadir=/data/mysql8
conf=$basedir/my.cnf
#在$bindir/mysqld_safe后面添加my.cnf的配置路径
$bindir/mysqld_safe --defaults-file="$conf" --datadir="$datadir"

启动服务:

#有两种方式启动
#一
/etc/init.d/mysqld8 start

#二,指定配置文件启动
 /usr/local/mysql8/bin/mysqld_safe  --defaults-file=/usr/local/mysql-8/my.cnf

用初始密码进入mysql,修改初始密码:

mysql -uroot -p"lfsjj9)-"

#修改密码
ALTER USER 'root'@'localhost'  IDENTIFIED WITH mysql_native_password BY '新密码'
FLUSH PRIVILEGES

你可能感兴趣的:(运维linux,mysql)