CentOS系统二进制安装MySQL 太过爱你忘了你带给我的痛 2022-06-06 02:15 191阅读 0赞 ### 1. 下载软件 ### 本次安装演示采用mysql-5.7.12版本 [https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.12-linux-glibc2.5-x86\_64.tar.gz][https_cdn.mysql.com_archives_mysql-5.7_mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz] -------------------- ### 2. 安装MySQL ### ##### 2.1 创建不可登录mysql用户 ##### groupadd mysql useradd -r -g mysql -s /bin/false mysql ##### 2.2 安装libaio ##### rpm -qa | grep libaio yum -y install libaio libaio-devel ##### 2.3 解压mysql安装包 ##### tar xzf mysql-5.7.12-linux-glibc2.5-x86\_64.tar.gz ##### 2.4 将源码包剪切到相应目录 ##### mv mysql-5.7.12-linux-glibc2.5-x86\_64 /usr/local/mysql ##### 2.5 复制配置文件 ##### cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf ##### 2.6 修改配置文件 ##### vim /etc/my.cnf basedir = /usr/local/mysql/ datadir = /usr/local/mysql/data socket = /tmp/mysql.sock ##### 2.7 初始化数据库 ##### cd /usr/local/mysql bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql > 命令参数解释: > > * defaults-file :制定MySQL配置文件路径 > * initialize :初始化随机密码,注意,初始化的密码是一个过期密码,登录后需要修改密码 > * user :指定账户 > > -------------------- > > 随机密码: > 2017-10-11T16:39:07.365065Z 1 \[Note\] A temporary password is generated for root@localhost: 9)J>7swK/Ue\_ -------------------- ### 3. 启动MySQL ### ##### 3.1 将 mysqld 加入 service 系统服务 ##### cp support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on ##### 3.2 启动mysql 服务器 ##### service mysqld start -------------------- ### 4. 配置环境变量 ### ##### 4.1 配置 mysql 环境变量 ##### vim /etc/profile # MySQL export PATH=$PATH:https:/usr/local/mysql/bin ##### 4.2 立即生效 ##### source /etc/profile -------------------- ### 5. 访问MySQL ### ##### 5.1修改密码 ##### mysql -u root -p Enter password: 9)J>7swK/Ue\_ ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysqlpasswd'; flush privileges; quit ##### 5.2 登录mysql ##### mysql -uroot -pmysqlpasswd mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2428 Server version: 5.7.12 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> [https_cdn.mysql.com_archives_mysql-5.7_mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz]: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
还没有评论,来说两句吧...