1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| 1、检查是否已经安装过mysql,执行命令 rpm -qa | grep mysql 删除相关目录或文件 验证是否删除完毕 whereis mysql find / -name mysql 2.检查mysql用户组和用户是否存在,如果没有,则创建 cat /etc/group | grep mysql cat /etc/passwd |grep mysql groupadd mysql useradd -r -g mysql mysql 3.上传安装包mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz 解压 tar zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz 4.移动到 /user/local下的mysql mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql 5.在/usr/local/mysql目录下创建data目录 mkdir /usr/local/mysql/data 6.更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限 chown -R mysql:mysql /usr/local/mysql chmod -R 755 /usr/local/mysql 7.cd /usr/local/mysql/bin 编译安装并初始化mysql,务必记住初始化输出日志末尾的密码(数据库管理员临时密码) ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
出错 rpm -qa|grep libaio yum install libaio-devel.x86_64 / apt-get install libaio1 libaio-dev yum -y install numactl 8.编辑配置文件my.cnf,添加配置如下 vi /etc/my.cnf
[mysqld] datadir=/usr/local/mysql/data port=3306 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES symbolic-links=0 max_connections=600 innodb_file_per_table=1 lower_case_table_names=1 character_set_server=utf8
9.测试启动mysql服务器 /usr/local/mysql/support-files/mysql.server start 10 添加软连接,并重启mysql服务 [root@localhost /]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql [root@localhost /]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql [root@localhost /]# service mysql restart 11.登录mysql,修改密码(密码为步骤5生成的临时密码) [root@localhost /]# mysql -u root -p Enter password: mysql>set password for root@localhost = password('yourpass');
12.开放远程连接 mysql>use mysql; msyql>update user set user.Host='%' where user.User='root'; mysql>flush privileges; 13.设置开机自动启动 1、将服务文件拷贝到init.d下,并重命名为mysql [root@localhost /]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 2、赋予可执行权限 [root@localhost /]# chmod +x /etc/init.d/mysqld 3、添加服务 [root@localhost /]# chkconfig --add mysqld 4、显示服务列表 [root@localhost /]# chkconfig --list
|