mysql 8 Linux企业版本安装

36 篇文章 0 订阅
14 篇文章 0 订阅
tar -Jxvf mysql-commercial-8.0.25-linux-glibc2.12-x86_64.tar.xz
mv mysql-commercial-8.0.25-linux-glibc2.12-x86_64 /usr/local/
# 软连接
ln -s /usr/local/mysql-commercial-8.0.25-linux-glibc2.12-x86_64 /usr/local/mysql8
# 创建MySQL组和用户
groupadd mysql
useradd -r -g mysql mysql
# 创建mysql数据目录 / 回到根目录
cd / && mkdir -p /data/mysql8_data/
# 授权
chown mysql:mysql -R /data/mysql8_data
chmod 750 /data/mysql8_data/ -R

# mysql.cnf参数配置
mv /etc/my.cnf /etc/my.cnfbak
vi /etc/my.cnf
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
port       = 3306
socket     = /tmp/mysql.sock
 
[mysqld]
port       = 3306
server-id  = 3306
user       = mysql
socket     = /tmp/mysql.sock
# 设置mysql的安装目录
basedir    = /usr/local/mysql8
# 设置mysql数据库的数据的存放目录
datadir    = /data/mysql8_data/mysql
log-bin    = /data/mysql8_data/mysql/mysql-bin
innodb_data_home_dir      =/data/mysql8_data/mysql
innodb_log_group_home_dir =/data/mysql8_data/mysql
#设置mysql数据库的日志及进程数据的存放目录
log-error =/data/mysql8_data/mysql/mysql.log
pid-file  =/data/mysql8_data/mysql/mysql.pid
# 服务端使用的字符集默认为8比特编码
character-set-server=utf8mb4
lower_case_table_names=1
autocommit =1
##################以上要修改的########################
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 1024
sort_buffer_size = 4M
net_buffer_length = 8K
read_buffer_size = 4M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 64M
thread_cache_size = 128
#query_cache_size = 128M
tmp_table_size = 128M
explicit_defaults_for_timestamp = true
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
 
binlog_format=mixed
 
binlog_expire_logs_seconds =864000
# 创建新表时将使用的默认存储引擎
default_storage_engine = InnoDB
innodb_data_file_path = ibdata1:10M:autoextend
innodb_buffer_pool_size = 1024M
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
transaction-isolation=READ-COMMITTED
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 4M
read_buffer = 2M
write_buffer = 2M
 
[mysqlhotcopy]
interactive-timeout
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
# 初始化MySQL
cd  /usr/local/mysql8/bin
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql8 --datadir=/data/mysql8_data/mysql --user=mysql --initialize
# 参数说明cp mysql.server /etc/init.d/mysqld

 

 chmod +x /etc/init.d/mysqld
# --defaults-file=/etc/my.cnf 指定配置文件(一定要放在最前面,至少 --initialize 前面)
# --user=mysql 指定用户(很关键)
# --basedir=/usr/local/mysql/ 指定安装目录
# --datadir=/usr/local/mysql/data/ 指定初始化数据目录

# 启动MySQL
cd /usr/local/mysql8/support-files/
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
#./mysqld_safe --defaults-file=/usr/local/etc/my.cnf &
# 查看是否启动
ps -ef|grep mysql #查看mysql 进程
netstat -ano |grep "3306" #查看3306端口

# 设置开机自启动
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start

# 加入环境变量
vi /etc/profile
#export PATH=$PATH:/usr/local/mysql8/bin
source /etc/profile

# 启动:service mysqld start
# 停止:service mysqld stop
# 重启:service mysqld restart
# 重载配置:service mysqld reload

# 更改MySQL密码 
cat /data/mysql8_data/mysql/mysql.log | grep password
# 2021-06-21T09:13:39.042896Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: mg6:AQL*1=h9
mysql -u root -p 
# mg6:AQL*1=h9



# 修改新密码123456:
ALTER USER 'root'@'localhost' IDENTIFIED with mysql_native_password BY '你的新密码';
flush privileges; #刷新权限
#首次改密推荐使用本地密码插件with mysql_native_password
 
use mysql;
select user,host,plugin,authentication_string from user;
CREATE user 'root'@'%'; #创建用户任意远程访问
alter user 'root'@'%' identified with mysql_native_password by '123456'; #修改密码
grant all privileges on *.* to "root"@"%"; #给用户授权
flush privileges; #刷新权限
# 更改具体用户远程访问
CREATE USER 'root'@'127.0.0.1' IDENTIFIED with mysql_native_password BY '123456'; # 创建'root'@'127.0.0.1'用户
flush privileges; #===> 记住刷新权限
update mysql.user set host='你要指定的主机ip' where user='root' and host = '127.0.0.1';
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值