MySQL Server 安装 ~ CentOS。

MySQL Server 安装 ~ CentOS。



卸载旧版本。

  • 查询现有 MySQL。
[root@192 ~]# rpm -qa | grep -i mysql

rpm -e --nodeps ...
  • 下载。

https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar

SecureCRT 使用 put - 文件全路径上传。

  • 解压。

tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar

mysql-community-client-5.7.29-1.el7.x86_64.rpm
mysql-community-common-5.7.29-1.el7.x86_64.rpm
mysql-community-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-embedded-5.7.29-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.29-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
mysql-community-server-5.7.29-1.el7.x86_64.rpm
mysql-community-test-5.7.29-1.el7.x86_64.rpm
  • 先安装依赖。
[root@192 mysql_geek]# rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-server-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
	mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.29-1.el7.x86_64
	mysql-community-common(x86-64) = 5.7.29-1.el7 is needed by mysql-community-server-5.7.29-1.el7.x86_64
	net-tools is needed by mysql-community-server-5.7.29-1.el7.x86_64
[root@192 mysql_geek]# rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-client-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
	mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.29-1.el7.x86_64

安装 libs 时出现

[root@192 mysql_geek]# sudo rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-libs-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
	mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.29-1.el7.x86_64
	mariadb-libs is obsoleted by mysql-community-libs-5.7.29-1.el7.x86_64

yum remove mysql-libs

清除之前的依赖。

  • 安装 mysql-community-common。

  • 安装 mysql-community-libs。

server 又依赖 net-tools。

[root@192 mysql_geek]# rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-server-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
	net-tools is needed by mysql-community-server-5.7.29-1.el7.x86_64

[root@192 mysql_geek]# yum install net-tools

综上。依赖顺序。

# yum remove mysql-libs
# rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm 
# rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm 
# rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm 
# rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm 


MySQL Server 启动。

先查看 MySQL Server 状态。

CentOS 7。

[root@192 mysql_geek]# systemctl status mysqld

CentOS 6。

service mysql status

启动。

[root@192 ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service



MySQL 客户端 ~ 密码问题。

一般安装时会打印安装日志信息。提示临时密码位置。

cat /root/.mysql_secret

如果没有就手动查看 MySQL 日志。

[root@192 ~]# cat /var/log/mysqld.log | grep password
2020-04-05T17:41:24.133433Z 1 [Note] A temporary password is generated for root@localhost: #we,eqv_=7PG
[root@192 ~]# cat /var/log/mysqld.log 
2020-04-05T17:41:23.298775Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-04-05T17:41:23.472998Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-04-05T17:41:23.497672Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-04-05T17:41:23.556554Z 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: aae18f2c-7764-11ea-a862-000c29a7c564.
2020-04-05T17:41:23.560085Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-04-05T17:41:23.959210Z 0 [Warning] CA certificate ca.pem is self signed.
2020-04-05T17:41:24.133433Z 1 [Note] A temporary password is generated for root@localhost: #we,eqv_=7PG
2020-04-05T17:41:26.405529Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-04-05T17:41:26.406978Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29) starting as process 27976 ...
2020-04-05T17:41:26.410224Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-04-05T17:41:26.410246Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-04-05T17:41:26.410249Z 0 [Note] InnoDB: Uses event mutexes
2020-04-05T17:41:26.410251Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-04-05T17:41:26.410254Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-04-05T17:41:26.410258Z 0 [Note] InnoDB: Using Linux native AIO
2020-04-05T17:41:26.410574Z 0 [Note] InnoDB: Number of pools: 1
2020-04-05T17:41:26.410722Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-04-05T17:41:26.414264Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-04-05T17:41:26.422756Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-04-05T17:41:26.432926Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-04-05T17:41:26.445753Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-04-05T17:41:26.459487Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-04-05T17:41:26.459586Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-04-05T17:41:26.473366Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-04-05T17:41:26.474088Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-04-05T17:41:26.474100Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-04-05T17:41:26.474266Z 0 [Note] InnoDB: Waiting for purge to start
2020-04-05T17:41:26.526026Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 2630069
2020-04-05T17:41:26.526273Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-04-05T17:41:26.537792Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-04-05T17:41:26.537811Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-04-05T17:41:26.538380Z 0 [Warning] CA certificate ca.pem is self signed.
2020-04-05T17:41:26.538422Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-04-05T17:41:26.540445Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-04-05T17:41:26.543385Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200406  1:41:26
2020-04-05T17:41:26.544551Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-04-05T17:41:26.544792Z 0 [Note] IPv6 is available.
2020-04-05T17:41:26.544805Z 0 [Note]   - '::' resolves to '::';
2020-04-05T17:41:26.544881Z 0 [Note] Server socket created on IP: '::'.
2020-04-05T17:41:26.551461Z 0 [Note] Event Scheduler: Loaded 0 events
2020-04-05T17:41:26.551564Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.29'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2020-04-05T17:48:11.163779Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)

mysql 客户端连接 MySQL Server。

[root@192 ~]# mysql -p #we,eqv_=7PG
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.29

Copyright (c) 2000, 2020, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.


修改密码。

第一次执行 sql,MySQL 会提示要先修改密码。

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password = password('root');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
  • 此时想要远程登录(使用 MySQL Workbench 或 SQLyog),会失败。是因为 MySQL Server 没有开启远程权限。


开启权限。

'root' 处为你设置的账户名。
by 'root'(密码) 处为你设置的密码。

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

  • 使用 flush privileges;,应用设置。
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lyfGeek

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值