MySQL8.0.26 在CentOS下的编译安装
mysql国内镜像地址:http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-8.0/
mysql官网地址:https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz
cd /home wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz tar -xvf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz mv mysql-8.0.26-linux-glibc2.12-x86_64 /usr/local/mysql cd /usr/lcal/mysql //添加mysql用户组和用户 groupadd mysql useradd -r -g mysql mysql //给mysql组/usr/local/mysql文件权限 chown -R mysql:mysql /usr/local/mysql //先配置下mysql配置文件。配置文件后面附上 vim /etc/my.cnf //安装个vim yum -y install vim //初始化mysql服务 ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //结束之后 cd data cat error.err //先保存下密码 chown -R root:root /usr/local/mysql chown -R mysql:mysql /usr/local/mysql/data --修改/etc/my.cnf配置文件权限 chmod 755 /etc/my.cnf
添加到开机自启
cd /usr/local/mysql --将mysql服务添加到/etc/init.d cp support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql --添加服务 chkconfig --add mysql --查看是否添加成功 chkconfig --list mysql
开启mysql并配置环境变量
//启动mysql服务 service mysql start //这里报错,如下图,查看报错日志缺少目录 mkdir /var/lib/mysql //再重新启动 vi /etc/profile //profile中填写内容: export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib //保存退出之后 source /etc/profile
登录测试
//这里使用的是初始密码,不知道可以去data/error.err里去找下 //上面有提醒 mysql -uroot -p //修改密码 alter user 'root'@'localhost' identified by 'root'; //添加用户wish 密码root的用户允许远程访问 create user `wish`@`%` identified by "root"; grant all on *.* to `wish` with grant option; //***这里要注意防火墙***//