时间:2021-07-01 10:21:17 帮助过:24人阅读
1.上传tar包到服务器并解压tar包到/usr/local/目录
cd /usr/local/
tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar
tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql
2.创建运行MySQL的用户和组(名字可以任意)
Shell> groupadd mysql
Shell> useradd mysql -g mysql
3.切换到mysql目录
Shell > mkdir data
4.修改解压包的权限
Shell> chown –R mysql
Shell> chgrp –R mysql
5.安装MySQL
Shell> bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data ##初始化数据目 录
shell> cp -f support-files/my-default.cnf /etc/my.cnf ##将默认配置文件复制到指定目录
shell> bin/mysqld_safe --datadir=/usr/local/mysql/data --user=mysql & ##启动MySQL服务
shell> cp support-files/mysql.server /etc/init.d/mysql.server ##将MySQL加入到服务自启动
Shell> /etc/init.d/mysql.server start ##通过服务启动MySQL
启动过程中如果碰到如下错误
[root@localhost mysql]# bin/mysqld --initialize --user=mysql --datadir /usr/local/mysql/data ? bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
则需要安装包yum install -y libaio
初始化过程中获得root的初始密码
修改root的初始密码
mysql> set password=password(‘mysql‘); ? Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges; ? Query OK, 0 rows affected (0.00 sec)
Linux下安装mysql 5.7
标签:set root mys 初始密码 image default /etc/ err 复制