1 下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz 复制这个链接在迅雷上下载比较快。
2 上传到centos服务器:scp mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz [email protected]:/usr/local
3 解压到 /usr/loacl 目录
4 重命名 mv mysql-5.7.24-linux-glibc2.12-x86_64 mysql
5 创建 mysql用户和组
groupadd mysql
useradd mysql -g mysql
6 进入mysql目录 创建data文件夹 mkdir data
7 修改mysql目录的用户权限 chown -R mysql.mysql
8 进入mysql/bin 目录 执行 ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 初始化mysql
如果报 ./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 这个错误,说明没有安装libaio 那么应该去安装libaio
rpm -qa|grep libaio 检查是否安装若未安装则执行:yum install libaio-devel.x86_64 安装。安装成功后进入mysql/bin目录再次执行
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
出现以下内容,说明初始化成功。@loaclhost 后面是初始化的登陆密码。
2018-11-24T15:36:01.283846Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-11-24T15:36:02.649660Z 0 [Warning] InnoDB: New log files created, LSN=45790 2018-11-24T15:36:02.765222Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2018-11-24T15:36:03.044910Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a6970d37-effe-11e8-8e3f-00163e2e8bb3. 2018-11-24T15:36:03.048345Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened. 2018-11-24T15:36:03.048905Z 1 [Note] A temporary password is generated for [email protected]: JHGFVKHG&#¥
9 添加mysql启动到本地服务 cp /usr/local/mysql/mysql.server /etc/init.d/mysql.server
10 启动mysql服务:service mysql.server start
看到
Starting MySQL.Logging to ‘/usr/local/mysql/data/iZ2ze2h6biv9bg5169c9gtZ.err‘. [ OK ]
就表示启动成功了。
11 设置环境变量,并使环境变量生效
export PATH=$PATH:/usr/local/mysql/bin
12 启动mysql ,密码是初始化使生成的默认密码。到此,完全完成myql的安装。
mysql -uroot -p
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff }
span.s1 { }
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff }
span.s1 { }
原文地址:https://www.cnblogs.com/bfyq/p/10014270.html