Mysql 5.7.40 部署安装
1.上传下载好的安装包
mysql-5.7.40-el7-x86_64.tar
2.安装Mysql
2.1解压安装包
tar -xf mysql-5.7.40-el7-x86_64.tar
tar -xvf mysql-5.7.40-el7-x86_64.tar.gz
将解压后的目录移动到/usr/local/下
mv mysql-5.7.40-el7-x86_64 /usr/local/mysql
创建数据目录
mkdir /data/mysqldata
2.2创建用户、组
groupadd mysql
useradd -g mysql mysql
2.3修改配置文件
vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysqldata
socket=/tmp/mysql.sock
log-error=/data/mysqldata/mysql.err
pid-file=/data/mysqldata/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
2.4 初始化数据库
./mysqld --initialize --user=mysql --datadir=/data/mysqldata/ --basedir=/usr/local/mysql/
初始化后会在日志文件内输出信息
cat /data/mysqldata/mysql.err
2023-04-20T09:37:58.848844Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-04-20T09:37:58.889050Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-04-20T09:37:58.941951Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 094f19a7-df5f-11ed-b280-f4e97577bc78.
2023-04-20T09:37:58.942201Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-04-20T09:37:59.106516Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-04-20T09:37:59.106523Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-04-20T09:37:59.107046Z 0 [Warning] CA certificate ca.pem is self signed.
2023-04-20T09:37:59.129064Z 1 [Note] A temporary password is generated for root@localhost: hoC2ztV=EKDy
2.5添加软连接,重启mysql服务
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql start
添加自启动
chkconfig --add mysql
2.6登录mysql 修改密码,访问权限
./mysql -h localhost -u root -p
hoC2ztV=EKDy
修改密码
set password=password('Mysql@2023');
flush privileges;
修改访问权限
use mysql;
update user set Host='%' where User='root';
flush privileges;