centos7.9 rpm方式安装mysql
一、下载安装包
https://downloads.mysql.com/archives/community/
二、安装依赖
2.1.一般centos7默认安装了mariadb,这里把它卸载。
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
2.2.安装所需要的依赖
yum install libaio perl net-tools
mysql -h110.110.110.110 -P 3306 -u root -p abcd123;(注:u与root之间可以不用加空格,其它也一样)
三、安装mysql
[root@bdc0002 soft]# rpm -ivh mysql-community-common-5.7.33-1.el7.x86_64.rpm warning: mysql-community-common-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-common-5.7.33-1.e################################# [100%] [root@bdc0002 soft]# rpm -ivh mysql-community-libs-5.7.33-1.el7.x86_64.rpm warning: mysql-community-libs-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-libs-5.7.33-1.el7################################# [100%] [root@bdc0002 soft]# rpm -ivh mysql-community-client-5.7.33-1.el7.x86_64.rpm warning: mysql-community-client-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-client-5.7.33-1.e################################# [100%] [root@bdc0002 soft]# rpm -ivh mysql-community-server-5.7.33-1.el7.x86_64.rpm warning: mysql-community-server-5.7.33-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-server-5.7.33-1.e################################# [100%]
启动:service mysqld start
查看:service mysqld status
四、修改密码
4.1查看临时密码
[root@bdc0002 soft]# grep password /var/log/mysqld.log 2021-06-17T09:16:50.335997Z 1 [Note] A temporary password is generated for root@localhost: 0dJZohDig7!9
4.2用临时密码登录mysql,修改密码
[root@bdc0002 soft]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.33 Copyright (c) 2000, 2021, Oracle and/or its affiliates. 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> set password = password("your_passwd");
4.3允许远程连接数据库
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_passwd' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.00 sec)
4.4修改配置文件
[root@bdc0002 ~]# vi /etc/my.cnf
#表名不区分大小写
lower_case_table_names=1
五、远程连接
mysql -h110.110.110.110 -P 3306 -u root -p abcd123;(注:u与root之间可以不用加空格,其它也一样)
连接串方式
jdbc:mysql://8.130.163.35:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false
?useUnicode=true&characterEncoding=UTF-8&useSSL=false
We only live once, and time just goes by.