mysql8.0.23 linux(Centos7)

MySQL8.0.23部署

  • 1.官网下载安装包

1.官网下载安装包

mysql8.0.23 linux(Centos7)_第1张图片
下载下来之后是tar.xz的需要进行两次解压
xz -d xxx.tar.xz 将 mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz.tar.xz解压成 mysql-8.0.23-linux-glibc2.12-x86_64.tar然后,再用 tar xvf mysql-8.0.23-linux-glibc2.12-x86_64.tar来解包。

[root@hadoop001 local]# rpm -qa|grep -i mysql  若有组件则卸载
[root@hadoop001 local]# rpm -qa|grep -i mariadb  若有组件则卸载
mariadb-libs-5.5.44-2.el7.centos.x86_6
[root@hadoop001 cdh5.16.1]# tar xzvf /root/cdh5.16.1/ysql-8.0.23-linux-glibc2.12-x86_64.tar -C /usr/local/
[root@hadoop39 local]#cd /usr/local
[root@hadoop39 local]# mv mysql-8.0.23-linux-glibc2.12-x86_64 mysql
[root@hadoop001 local]# mkdir mysql/arch mysql/data mysql/tmp mysql/relay_log

改/etc/my.cnf文件

[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
default-character-set=utf8mb4

[mysqld]
port = 3306
socket  = /usr/local/mysql/data/mysql.sock
character-set-server=utf8mb4
default_authentication_plugin=mysql_native_password
default-storage-engine = INNODB
server-id  = 1739
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/hostname.pid
#open performance schema
binlog_format = ROW
log_bin_trust_function_creators=1
log-error = /usr/local/mysql/data/hostname.err
log-bin = /usr/local/mysql/arch/mysql-bin
#expire_logs_days = 7
binlog_expire_logs_seconds = 10080
relay-log  = /usr/local/mysql/relay_log/relay-log
relay-log-index = /usr/local/mysql/relay_log/relay-log.index
relay_log_info_file= /usr/local/mysql/relay_log/relay-log.info
innodb_data_home_dir = /usr/local/mysql/data/
#根据生产需要,调整pool size
innodb_buffer_pool_size = 2G
tmpdir = /usr/local/mysql/tmp
lower_case_table_names=1

在 /etc/security/limits.conf 文件中加入:

* hard nofile 65535
* soft nofile 65535
[root@hadoop001 local]# groupadd -g 101 dba
[root@hadoop001 local]# useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
[root@hadoop001 local]# cp /etc/skel/.* /usr/local/mysql
[root@hadoop001 local]# vi mysql/.bashrc
追加:
export MYSQL_BASE=/usr/local/mysql
export PATH=${MYSQL_BASE}/bin:$PATH
unset USERNAME
#stty erase ^H
set umask to 022
umask 022
PS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1


[root@hadoop001 local]# chown  mysqladmin:dba /etc/my.cnf 
[root@hadoop001 local]# chmod  640 /etc/my.cnf  
[root@hadoop001 local]# chown -R mysqladmin:dba /usr/local/mysql
[root@hadoop001 local]# chmod -R 755 /usr/local/mysql 
[root@hadoop001 local]# cd /usr/local/mysql
#将服务文件拷贝到init.d下,并重命名为mysql
[root@hadoop001 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql 
#赋予可执行权限
[root@hadoop001 mysql]# chmod +x /etc/rc.d/init.d/mysql
#删除服务
[root@hadoop001 mysql]# chkconfig --del mysql
#添加服务
[root@hadoop001 mysql]# chkconfig --add mysql
[root@hadoop001 mysql]# chkconfig --level 345 mysql on
#安装libaio及安装mysql的初始db 
[root@hadoop39 mysql]# yum -y install libaio
[root@hadoop39 mysql]# sudo su - mysqladmin
hadoop001:mysqladmin:/usr/local/mysql:>bin/mysqld --defaults-file=/etc/my.cnf  --user=mysqladmin  --basedir=/usr/local/mysql/  --datadir=/usr/local/mysql/data/  --lower-case-table-names=1 --initialize

然后去#查看临时密码:
hadoop001:mysqladmin:/usr/local/mysql/data:>cat hostname.err

#启动
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &

初始修改密码:

#进入mysql 控台
mysql  mysql -uroot -p
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';  

远程授权: MySQL 8不允许在授权的时候创建用户
mysql> create user 'zlk' identified by 'zlk123';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zlk.* to zlk@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;

授权还可以根据以下: 
use mysql;
update user set host = '%' where user = 'root';
#刷新权限
flush privileges;  

你可能感兴趣的:(MySQL)