CentOs7通过yum安装mysql和tomcat
安装mysql
安装YUM Repo
//由于CentOS 的yum源中没有mysql,需要到mysql的官网下载yum repo配置文件。
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
//repo的安装
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
安装MySQL
yum install mysql-server
启动msyql
systemctl start mysqld.service
查看mysql运行状态
systemctl status mysqld.service
[root@localhost mysql]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-08-27 18:53:48 CST; 17s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 3827 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 3744 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
获取mysql安装时的临时密码
grep 'temporary password' /var/log/mysqld.log
[root@localhost mysql]# grep 'temporary password' /var/log/mysqld.log
2019-08-27T10:53:41.774424Z 1 [Note] A temporary password is generated for root@localhost: aP=hPefJR84g
登录mysql
mysql -u root -p //注意,按回车键后输入上述显示的临时密码,在密码输入时密码框不会发生任何变化,密码输入完成后点击回车,即可成功进入mysql
[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.27
修改登录密码
mysql安装进入后必须先修改密码,不修改密码进行任何操作都会报错Your password does not satisfy the current policy requirements
刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
如果你想要设置一个简单的测试密码的话,比如设置为123456,会提示这个错误,报错的意思就是你的密码不符合要求
mysql> alter user 'root'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决方案:
1. 修改validate_password_policy参数的值
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
2.validate_password_length(密码长度)参数默认为8,修改为1
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
3.再次设置新的密码为简单密码即可成功
例如,设置为123456
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
//设置修改的密码永不过期
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql开启关闭
systemctl stop mysqld #关闭MySQL
systemctl restart mysqld #重启MySQL
systemctl status mysqld #查看MySQL运行状态
systemctl enable mysqld #设置开机启动
systemctl disable mysqld #关闭开机启动
mysql远程访问设置
grant all privileges on *.* to 'root' @'%' identified by 'root';
flush privileges; //刷新内容
mysql> grant all privileges on *.* to 'root' @'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
安装tomcat
// 安装tomcat
[root@localhost ~]# yum -y install tomcat
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
//检测tomcat是否安装成功
[root@localhost ~]# rpm -q tomcat
tomcat-7.0.76-9.el7_6.noarch
作 者:sweetheart1998
出 处:https://home.cnblogs.com/u/gujun1998/
如有问题或建议,请多多赐教!
版权声明:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。
如果您觉得文章对您有帮助,可以点击文章右下角推荐一下!