Linux下安装tomcat

Linux下安装tomcat

1.Windows下载mysql

在官网: https://dev.mysql.com/downloads/mysql/ 中, 选择以下版本的mysql下载 :

 

 

2.Linux下载mysql

[root@instance-0pk09gjj local]# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-linux-glibc2.12-x86_64.tar

3. 减压mysql

[root@instance-0pk09gjj local]# tar -zxvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

[root@instance-0pk09gjj local]# cp -rf mysql-5.7.20-linux-glibc2.12-x86_64 /usr/local/mysql

4.添加用户组和用户

添加用户组

[root@instance-0pk09gjj local]# groupadd mysql

添加用户mysql 到用户组mysql

[root@instance-0pk09gjj local]# useradd -g mysql mysql

将mysql目录访问权限赋为myql用户

[root@instance-0pk09gjj local]# chown -R mysql mysql/

 

5.安装

[root@instance-0pk09gjj mysql]# vi /etc/my.cnf

[mysqld]

# mysql安装目录
basedir=/usr/local/mysql-5.7 

# mysql数据存放目录      
datadir=/usr/local/mysql-5.7/data
socket=/usr/local/mysql-5.7/data/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
 

初始化数据库

[root@instance-0pk09gjj mysql]# bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

添加启动服务

[root@instance-0pk09gjj mysql]# cp support-files/mysql.server /etc/init.d/mysql

[root@instance-0pk09gjj mysql]# chmod 755 /etc/init.d/mysql

修改 

[root@instance-0pk09gjj support-files]# vi /etc/init.d/mysql

basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data

6.登录

[root@instance-0pk09gjj mysql-5.7]# bin/mysql -uroot -p

7.重置密码

mysql> set password=password('mysql');

 

问题总结:

(1) 启动mysql时遇到这样一个错误

[root@instance-0pk09gjj mysql]# service mysql start
Starting MySQL.2018-11-29T07:23:52.793599Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
The server quit without updating PID file (/var/lib/mysql/i[FAILED]0pk09gjj.pid).
 

解决方案:

[root@instance-0pk09gjj mysql]# mkdir /var/log/mariadb
[root@instance-0pk09gjj mysql]# touch /var/log/mariadb/mariadb.log
[root@instance-0pk09gjj mysql]# chown -R mysql:mysql /var/log/mariadb/

(2) 错误内容

[root@instance-0pk09gjj mysql-5.7]# bin/mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
 

解决方案:

[root@instance-0pk09gjj mysql-5.7]# ln -s /usr/local/mysql-5.7/data/mysql.sock /tmp/mysql.sock

 

mysql.sock 这个文件的地址是配置在 /etc/my.cnf 文件中, 启动mysql时生成这个文件, 上面这个命令时把你的mysql.sock文件软连接到/tmp/mysql.sock中; 最后重新登录mysql就ok了.

(3) 错误内容

如果mysql服务启动成功后,通过navicat等客户端连接不成功时,说明安装mysql的服务器ip不是mysql默认的那几个.解决方案:

解决方案:

mysql> use mysql;

mysql> update user set host = '%' where user = 'root';

mysql> flush privileges;

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值