吻星揽月

导航

CentOS7.5下,MySQL安装配置指南

[root@host-10-133-1-134 home]# grep 'temporary password' /var/log/mysqld.log
2019-03-20T02:21:56.457613Z 1 [Note] A temporary password is generated for root@localhost: qAD44%hu?afp

 

[root@host-10-133-1-134 home]# uname -a
Linux host-10-133-1-134 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@host-10-133-1-134 home]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@host-10-133-1-134 home]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

[root@host-10-133-1-134 home]# rpm -qa | grep mysql
[root@host-10-133-1-134 home]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64

[root@host-10-133-1-134 home]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[root@host-10-133-1-134 home]# rpm -qa | grep mariadb
[root@host-10-133-1-134 home]# rpm -qa | grep mysql

[root@host-10-133-1-134 home]# rpm -ivh mysql-community-common-5.7.25-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.25-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.25-1.e################################# [100%]
[root@host-10-133-1-134 home]# rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.25-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.25-1.el7################################# [100%]
[root@host-10-133-1-134 home]# rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.25-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.25-1.e################################# [100%]
[root@host-10-133-1-134 home]# rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.25-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.25-1.e################################# [100%]

systemctl start mysqld.service    //启动mysql
systemctl status mysqld.service  //查看mysql状态
systemctl stop mysqld.service    //关闭mysql

[root@host-10-133-1-134 home]# ps -ef | grep mysql
mysql    24891     1  0 10:21 ?        00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root     24978 24025  0 10:28 pts/1    00:00:00 grep --color=auto mysql
[root@host-10-133-1-134 home]# netstat -nltp|grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      24891/mysqld

[root@host-10-133-1-134 home]# grep 'temporary password' /var/log/mysqld.log
2019-03-20T02:21:56.457613Z 1 [Note] A temporary password is generated for root@localhost: qAD44%hu?afp
//使用如下命令登录数据库,输入上面查询到的密码:
[root@host-10-133-1-134 ~]# mysql -u root -p

//进入数据库,使用命令set password=password("Huawei12#$");修改数据库密码。

mysql> grant all privileges on *.* to root@"%" identified by "Huawei12#$";
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

//配置字符编码UTF-8
//vi /etc/my.cnf
#添加
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'


配置文件:/etc/my.cnf 
日志文件:/var/log//var/log/mysqld.log 
服务启动脚本:/usr/lib/systemd/system/mysqld.service 
socket文件:/var/run/mysqld/mysqld.pid

 

posted on 2019-03-20 11:45  吻星揽月  阅读(275)  评论(0编辑  收藏  举报