mysql源码安装

Linux环境

1、mysql下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

下载参考:

在这里插入图片描述

2、把下载的 MySQL 压缩包上传到 Linux 服务器

3、解压mysql-5.7.39-linux-glibc2.12-x86_64.tar.gz

tar -zxvf mysql-5.7.39-linux-glibc2.12-x86_64.tar.gz

4、把解压后的文件移动到 /usr/local 目录下

mv mysql-5.7.39-linux-glibc2.12-x86_64 /usr/local/mysql

5、创建MySQL组合用户

groupadd mysql

useradd -r -g mysql mysql

6、创建数据存储目录

mkdir /usr/local/mysql/data

7、修改相关权限

chown -R mysql:mysql /usr/local/mysql

chmod -R 777 /usr/local/mysql/

8、MySQL初始化操作,记录临时密码

cd /usr/local/mysql/bin

./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

输出内容如下:

[root@hecs-399223 bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2023-10-27T06:29:18.581041Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-10-27T06:29:18.826360Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-10-27T06:29:18.868528Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-10-27T06:29:18.928878Z 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: 288aaf07-7492-11ee-8151-fa163e92ea6c.
2023-10-27T06:29:18.931018Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-10-27T06:29:19.409290Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-10-27T06:29:19.409316Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-10-27T06:29:19.409839Z 0 [Warning] CA certificate ca.pem is self signed.
2023-10-27T06:29:19.670575Z 1 [Note] A temporary password is generated for root@localhost: Y2Eu.8du7Fi<

注意:复制保存 MySQL初始化密码 Y2Eu.8du7Fi<

9、创建MySQL配置文件 /etc/my.cnf,执行如下命令即可自动创建

cat > /etc/my.cnf <<EOF
[mysqld]
port = 3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
max_connections=200
max_connect_errors=10
character-set-server=utf8mb4
default_authentication_plugin=mysql_native_password

[mysql]
default-character-set=utf8mb4

[client]
port=3306
default-character-set=utf8mb4
EOF

10、配置开机自启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

启动mysql

systemctl start mysqld

11、设置环境变量

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

source /etc/profile

12、通过临时密码登录MySQL并修改密码

#登录
mysql -u root -p
ALTER USER 'root' @'localhost' IDENTIFIED BY '123456';

flush privileges;

13、开启远程访问

grant all privileges on *.* to "root"@"%" identified by "123456";  

flush privileges;

13、开启远程访问

grant all privileges on *.* to "root"@"%" identified by "123456";  

flush privileges;

安装结束!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值