第一步下载
https://dev.mysql.com/downloads/mysql/
![a290b44a746e27b9c20c91efb55241c5.png](https://i-blog.csdnimg.cn/blog_migrate/1e136706aed99abde4e066e36c241005.jpeg)
![ecaa564376b6a20c5ff96ba013df0662.png](https://i-blog.csdnimg.cn/blog_migrate/97e54241cb2c9e500f5e813e1d831875.jpeg)
第二步上传到服务器
tar -zxvf mysql-8.0.13-el7-x86_64.tar.gzcd mysql-8.0.13-el7-x86_64mv mysql-8.0.13-el7-x86_64 mysql8.0.13_x64
第三步 创建 mysql 用户组和 mysql 用户
groupadd mysqluseradd -g mysql mysql
第四步 改变 mysql 目录权限
chown -R mysql.mysql /usr/local/ mysql8.0.13_x64/
第五步 mysql配置
[mysql]default-character-set=utf8mb4socket=/var/lib/mysql/mysql.sock[client]default-character-set=utf8mb4socket=/var/lib/mysql/mysql.sock[mysqld]user=mysqlskip-name-resolveserver-id=1port=3306lower_case_table_names=1socket=/var/lib/mysql/mysql.sockbasedir=/usr/local/mysql-8.0.13_x64datadir=/usr/local/mysql-8.0.13_x64/datamax_connections=800character-set-server=utf8mb4default-storage-engine=INNODBmax_allowed_packet=16Minnodb_buffer_pool_size=1Ginnodb_flush_log_at_trx_commit=2binlog_format=MIXEDlog-bin=/usr/local/mysql-8.0.13_x64/logs/binlog/mysql-logbinlog-ignore-db=mysqldefault_authentication_plugin=mysql_native_passwordsql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
第六步 执行 ./mysqld –initialize-insecure 默认空密码
出现以下错误
需要安装 libnuma
yum install libnuma
yum -y install numactl
yum install libaio1 libaio-dev
./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
第七步建立MySQL服务
cp -a ./support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/rc.d/init.d/mysqld chkconfig --add mysqld
可以检查一下服务是否生效
chkconfig --list
第八步 配置全局环境
vi /etc/profileexport MYSQL_HOME=/usr/local/mysql-8.0.13_x64PATH=$MYSQL_HOME/bin:$PATHexport PATH
保存退出,使环境变量生效
source /etc/profile
第九步 启动mysql服务,关闭和重启
service mysqld startservice mysqld stop service mysqld restart
第十步
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码'; mysql>update user set host='%' where user='root' limit 1;
// 刷新权限
mysql>flush privileges;
然后检查3306端口是否开放
netstat -nupl|grep 3306
开放3306端口
firewall -cmd --permanent --add-prot=3306/tcp
重启防火墙
firewall -cmd --reload
错误一
![c30683e939c591f36a231def59282ddd.png](https://i-blog.csdnimg.cn/blog_migrate/6cec91effd1faa7c1d4c7b3d82aa1e78.jpeg)
把share/english下面的errmsg.sys复制到share目录下面
文章是本人在工作中学习终结得到,如果有不对的基地,请小伙伴们私聊或者评论一起探讨。