赞
踩
[zoro@localhost ~]$
[zoro@localhost ~]$ su root
密码:
[root@localhost zoro]#
[root@localhost zoro]# cd /root
[root@localhost ~]#
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# ls
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# rpm -qa |grep mariadb
mariadb-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-server-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-server-5.5.56-2.el7.x86_64
[root@localhost ~]#
[root@localhost ~]# rpm -qa |grep mariadb
[root@localhost ~]#
小Tips 它来了
//linux 中复制粘贴会很麻烦吧,鼠标右键选复制粘贴
//但是我带来了一个快捷键
Ctrl+insert 复制选中的部分
Shift+insert 粘贴选中的部分
[root@localhost ~]# rpm -qa |grep libaio
[root@localhost ~]#
[root@localhost ~]# yum -y install libaio
// 安装好后查看
[root@localhost ~]# rpm -qa |grep libaio
libaio-0.3.109-13.el7.x86_64
[root@localhost ~]# rpm -qa | grep numactl
[root@localhost ~]#
[root@localhost ~]# yum -y install numactl
// 安装好后查看
[root@localhost ~]# rpm -qa | grep numactl
numactl-libs-2.0.9-7.el7.x86_64
准备工作完毕!!!
[root@localhost ~]# tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost ~]# cd /usr/local
[root@localhost local]# groupadd mysql
[root@localhost local]# useradd -g mysql mysql
//修改文件用户
[root@localhost local]# chown -R mysql mysql/
//修改文件用户组
[root@localhost local]# chgrp -R mysql mysql/
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 9 mysql mysql 129 3月 21 19:23 mysql
[root@localhost local]# mkdir /usr/local/mysql/data
[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
2024-03-21T12:07:05.707693Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-03-21T12:07:05.892450Z 0 [Warning] InnoDB: New log files created, LSN=45790
2024-03-21T12:07:05.921089Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2024-03-21T12:07:05.978535Z 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: 88f48a25-e77b-11ee-a66d-000c29829cfb.
2024-03-21T12:07:05.979261Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-03-21T12:07:05.980080Z 1 [Note] A temporary password is generated for root@localhost: 复制密码
[root@localhost local]# vi /etc/my.cnf
小Tips
/** 会进入一个空文件,点检insert按钮开始编辑
* Shift+insert 粘贴
* 点击esc,退出编辑
* Shift + : 按钮一起点击
* 出现 :
* 然后wq保存退出
*/
# 服务端使⽤的字符集默认为8⽐特编码的latin1字符集
character-set-server=utf8
:wq //这样
复制下面的
[mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 socket=/var/lib/mysql/mysql.sock [mysqld] skip-name-resolve #设置3306端⼝ port = 3306 socket=/var/lib/mysql/mysql.sock # 设置mysql的安装⽬录 basedir=/usr/local/mysql # 设置mysql数据库的数据的存放⽬录 datadir=/usr/local/mysql/data # 允许最⼤连接数 max_connections=200 # 服务端使⽤的字符集默认为8⽐特编码的latin1字符集 character-set-server=utf8 # 创建新表时将使⽤的默认存储引擎 default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=16M
[root@localhost mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]#
复制启动脚本到资源⽬录
[root@localhost mysql]# vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
# Value here is overriden by value in my.cnf.
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900
# Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql"
:wq
:wq 保存退出
小Tips
/* / 斜杠 后面写自己找的关键字可以找到,其他的你可以网上查找一下吧,好像能找最附近的,呵呵哈哈哈
\basedir
//授权为可执行状态 //⾸先增加 mysqld 服务控制脚本执⾏权限: [root@localhost mysql]# chmod +x /etc/init.d/mysqld //开机启动 //同时将 mysqld 服务加⼊到系统服务: [root@localhost mysql]# chkconfig --add mysqld //最后检查 mysqld 服务是否已经⽣效即可: [root@localhost mysql]# chkconfig --list mysqld 注:该输出结果只显示 SysV 服务,并不包含 原生 systemd 服务。SysV 配置数据 可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。 查看在具体 target 启用的服务请执行 'systemctl list-dependencies [target]'。 mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关 [root@localhost mysql]#
[root@localhost mysql]# service mysqld start
Starting MySQL. [ 确定 ]
[root@localhost mysql]#
配置环境变量
[root@localhost ~]# vi /etc/profile
//添加下面一行wq保存退出
export PATH=$PATH:/usr/local/mysql/bin
:wq
[root@localhost ~]#
//
[root@localhost ~]# source /etc/profile
[root@localhost mysql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> set password for root@localhost = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set user.Host='%' where user.User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
但是还是有问题
windows 上的Navicat是连接不上的
BY 后面是数据库密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>quit
Bye
[root@localhost mysql]# cd /root
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@localhost ~]# systemctl restart firewalld.service
[root@localhost ~]#
[root@localhost ~]# firewall-cmd --list-ports
3306/tcp
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。