编译安装mysql

准备用户并创建目录,准备实验环境

[root@localhost ~]# groupadd -r -g 306 mysql
[root@localhost ~]# useradd -r -g 306 -u 306 -d /data/mysql mysql
[root@localhost ~]# mkdir /data/mysql
[root@localhost ~]# chown mysql:mysql /data/mysql
[root@localhost ~]# yum install -y libaio perl-Data-Dumper  vim gcc gcc-c++ wget autoconf net-tools lrzsz curl policycoreutils openssh-server openssh-clients postfix  
[root@localhost ~]# tar xf ~/mysql-5.7.29-el7-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@localhost ~]# source /etc/profile

开始安装Mysql5.7

[root@localhost ~]# cd /usr/local/
[root@localhost ~]# mv /usr/local/src/mysql-5.7.29-el7-x86_64 /usr/local/mysql
[root@localhost src]# mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
2021-03-28T03:37:04.164075Z 1 [Note] A temporary password is generated for root@localhost: rk>bsXkum7ud
[root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig  mysqld on
[root@localhost ~]# chkconfig --list |grep mysqld

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@localhost ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/mysql_error.log'.
.... SUCCESS! 
[root@localhost ~]# /usr/local/mysql/bin/mysql_secure_installation 
更改密码

验证

[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29-log

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)


©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容