欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CentOS 7 配置java web 环境(安装mysql数据库)

程序员文章站 2022-07-06 15:47:05
...

 

虽然关于服务器的配置网上有很多,但大多都有各种问题,服务器提供商不同。

没办法,所以自己记录一下

一丶配置mysql数据库

rpm -qa|grep -i mysql

查看服务器中有没有安装mysql,如果如下图所示,则没有。如果有安装,需要删除卸载后再安装,卸载方法自行百度

CentOS 7 配置java web 环境(安装mysql数据库)

创建mysql路径并cd过去,如下图所示

CentOS 7 配置java web 环境(安装mysql数据库)

运行以下 三条下载安装命令

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm 
rpm -ivh mysql57-community-release-el7-8.noarch.rpm 
yum -y install mysql-server 

默认配置文件路径: 

配置文件:/etc/my.cnf 

日志文件:/var/log/var/log/mysqld.log 

服务启动脚本:/usr/lib/systemd/system/mysqld.service 

socket文件:/var/run/mysqld/mysqld.pid

 

执行以下命令安装vim工具

yum install -y vim*

配置  my.cnf       

vim /etc/my.cnf
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
server_id = 1
expire_logs_days = 3

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

按i进入编辑模式,改完后按Esa,再按住Shift+两下Z保存并退出

启动mysql服务

service mysqld restart
grep "password" /var/log/mysqld.log   

[email protected]: 后面既是密码

CentOS 7 配置java web 环境(安装mysql数据库)

 

输入查找到的密码登录

alter user 'root'@'localhost' identified by '修改后密码';  
CREATE USER 'koow'@'%' IDENTIFIED BY '注册用户密码';
grant all on *.* to '赋予权限的用户名'@'%' identified by '用户名密码'  with grant option;



flush privileges;
exit;

以上就是mysql安装全过程,默认端口号3306
 

相关标签: CentOS 7