-
在Xftp把本地的MySQLLinux安装包移动到/opt/install里
-
解压
.tar.gz后缀:tar -zxvf ./文件名
.tar.xz后缀:tar -Jxvf ./文件名 -
重命名+移动
mv 原文件名 重命名
mv 当前文件夹下的文件 绝对地址的文件夹位置
mv mysql-8.0.31-linux-glibc2.12-x86_64 mysql8 mv mysql8 /opt/soft
-
在mysql8 中创建datas文件夹
mkdir datas
-
创建用户组和用户
#创建一个用户组:mysql
groupadd mysql
#创建一个系统用户:mysql,指定用户组为mysql
useradd -r -g mysql mysql
-r:创建系统用户 -g:指定用户组
-
将datas权限修改
更改属主和数组
chown -R mysql:mysql /opt/soft/mysql8/datas
更改模式
chmod -R 750 /opt/soft/mysql8/datas
-
安装vim
yum install -y vim
-
配置环境变量
vim /etc/profile
#出现行号 :set nu #按a进入配置 按esc结束配置 74 #mysql_home 75 export PATH=$PATH:/opt/soft/mysql8/bin
-
配置my.cnf
vim ./my.cnf
[mysql] # 默认字符集 default-character-set=utf8mb4 [client] port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 server-id = 3306 user = mysql socket = /tmp/mysql.sock # 安装目录 basedir = /opt/soft/mysql8 # 数据存放目录 datadir = /opt/soft/mysql8/datas/mysql log-bin = /opt/soft/mysql8/datas/mysql/mysql-bin innodb_data_home_dir =/opt/soft/mysql8/datas/mysql innodb_log_group_home_dir =/opt/soft/mysql8/datas/mysql #日志及进程数据的存放目录 log-error =/opt/soft/mysql8/datas/mysql/mysql.log pid-file =/opt/soft/mysql8/datas/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
:wq 退出编辑
-
资源加载
source /etc/profile
-
初始化
mysqld --defaults-file=/opt/soft/mysql8/my.cnf --basedir=/opt/soft/mysql8/ --datadir=/opt/soft/mysql8/datas/mysql --user=mysql --initialize-insecure
-
启动服务
mysqld_safe --defaults-file=/opt/soft/mysql8/my.cnf &
-
查看是否启动
ps -ef|grep mysql
-
登录
mysql -uroot --skip-password
-
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
flush privileges;
-
允许远程登录
use mysql; update user set user.Host='%' where user.User='root';
flush privileges;
-
重新进入MySQL
exit mysql -uroot -p root