The Tenth Week (Lucklyzpp)
1、通过编译、二进制安装MySQL5.7
root@Lucklyzpp ~]# ls anaconda-ks.cfg a.txt mysql-5.7.35-linux-glibc2.12-x86_64.tar [root@Lucklyzpp ~]# yum -y install libaio numactl-libs 已加载插件:fastestmirror Loading mirror speeds from cached hostfile 软件包 libaio-0.3.109-13.el7.x86_64 已安装并且是最新版本 软件包 numactl-libs-2.0.12-5.el7.x86_64 已安装并且是最新版本 无须任何处理 [root@Lucklyzpp ~]# groupadd mysql [root@Lucklyzpp ~]# useradd -r -g mysql -s /bin/false mysql [root@Lucklyzpp ~]# ls anaconda-ks.cfg a.txt mysql-5.7.35-linux-glibc2.12-x86_64.tar [root@Lucklyzpp ~]# tar xf mysql-5.7.35-linux-glibc2.12-x86_64.tar -C /usr/local [root@Lucklyzpp ~]# cd /usr/local/ [root@Lucklyzpp local]# ls bin include libexec sbin etc lib mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz share games lib64 mysql-test-5.7.35-linux-glibc2.12-x86_64.tar.gz src [root@Lucklyzpp local]# tar xf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz [root@Lucklyzpp local]# ls bin lib mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz src etc lib64 mysql-test-5.7.35-linux-glibc2.12-x86_64.tar.gz games libexec sbin include mysql-5.7.35-linux-glibc2.12-x86_64 share [root@Lucklyzpp local]# ln -s mysql-5.7.35-linux-glibc2.12-x86_64/ mysql [root@Lucklyzpp local]# ls bin lib mysql-5.7.35-linux-glibc2.12-x86_64 share etc lib64 mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz src games libexec mysql-test-5.7.35-linux-glibc2.12-x86_64.tar.gz include mysql sbin [root@Lucklyzpp local]# chown -R root:root /usr/local/mysql [root@Lucklyzpp local]# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh [root@Lucklyzpp local]# . /etc/profile.d/mysql.sh [root@Lucklyzpp local]# cp /etc/my.cnf{,.bak} [root@Lucklyzpp local]# vim /etc/my.cnf [root@Lucklyzpp local]# cp /etc/my.cnf /etc/my.cnf2.bak [root@Lucklyzpp local]# vim /etc/my.cnf [root@Lucklyzpp local]# mysqld --initialize --user=mysql --datadir=/data/mysql [root@Lucklyzpp local]# grep password /data/mysql/mysql.log 2021-08-28T11:49:44.176490Z 1 [Note] A temporary password is generated for root@localhost: /a;P?VYjk5Md [root@Lucklyzpp local]# cp /usr/local/mysql mysql/ mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz mysql-5.7.35-linux-glibc2.12-x86_64/ mysql-test-5.7.35-linux-glibc2.12-x86_64.tar.gz [root@Lucklyzpp local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@Lucklyzpp local]# chkconfig --add mysqld [root@Lucklyzpp local]# service mysqld start Starting MySQL. SUCCESS! [root@Lucklyzpp local]# mysqladmin -uroot -p'/a;P?VYjk5Md' password zhengpengpeng@1 mysqladmin: [Warning] Using a password on the command line interface can be insecure. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety. [root@Lucklyzpp local]# mysql -uroot -pzhengpengpeng@1 mysql>
2、二进制安装mariadb10.4
#mysql用户组和用户的创建 groupadd -r mysql useradd -r -g mysql -s /sbin/nologin mysql #压缩包解压到指定目录 tar xvf mariadb-10.5.5-linux-x86_64.tar.gz -C /usr/local #进入解压缩目录 cd /usr/local #建立软连接并更改权限 ln -s mariadb-10.5.5-linux-x86_64/ mysql chown -R root.root /usr/local/mysql/ #准备配置文件 vim /etc/my.cnf [mysqld] datadir=/data/mysql skip_name_resolve=1 socket=/data/mysql/mysql.sock log-error=/data/mysql/mysql.log pid-file=/data/mysql/mysql.pid [client] socket=/data/mysql/mysql.sock [mysql] auto-rehash prompt="\u@\h [\d]>" #进入mysql目录 cd mysql #数据库文件初始化 ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql #环境变量设置 方法1 echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh . /etc/profile.d/mysql.sh 方法2 ln -s /usr/local/mysql/bin/* /usr/local/bin/ #准备服务脚本 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld #启动mysql chkconfig --add mysqld service mysqld start #修改root登录口令 mysqladmin -uroot password zhengpengpeng@1 #登录mysql mysql -uroot -pzhengpengpeng@1