Linux下MySql安装记录

1,centos自带mariadb,需要提前卸载

# 检查是否安装了mariadb
root[/root]#rpm -qa |grep -i mariadb
mariadb-5.5.52-1.el7.x86_64
mariadb-server-5.5.52-1.el7.x86_64
# 卸载
root[/root]#rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64
root[/root]#rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64
# 检查是否卸载
root[/root]#find / -iname mariadb

2,上传mysql安装包,安装其中四个

root[/root/Downloads]#tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 
mysql-community-embedded-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-test-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-libs-5.7.29-1.el7.x86_64.rpm
mysql-community-client-5.7.29-1.el7.x86_64.rpm
mysql-community-server-5.7.29-1.el7.x86_64.rpm
mysql-community-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
mysql-community-common-5.7.29-1.el7.x86_64.rpm

root[/root/Downloads]#rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-common-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.29-1.e################################# [100%]
root[/root/Downloads]#
root[/root/Downloads]#
root[/root/Downloads]#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
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.29-1.el7################################# [100%]
root[/root/Downloads]#
root[/root/Downloads]#
root[/root/Downloads]#
root[/root/Downloads]#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
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.29-1.e################################# [100%]
root[/root/Downloads]#
root[/root/Downloads]#
root[/root/Downloads]#
root[/root/Downloads]#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
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.29-1.e################################# [100%]

3,启动mysql,查看临时密码,修改密码

root[/root/Downloads]#service mysqld start
Redirecting to /bin/systemctl start  mysqld.service

root[/root/Downloads]#service mysqld status
Redirecting to /bin/systemctl status  mysqld.service
* mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-01-17 17:31:50 CST; 1min 9s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 9309 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 9259 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 9312 (mysqld)
   CGroup: /system.slice/mysqld.service
           `-9312 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Jan 17 17:31:41 master systemd[1]: Starting MySQL Server...
Jan 17 17:31:50 master systemd[1]: Started MySQL Server.
root[/root/Downloads]#cat /var/log/mysqld.log | more
2020-01-17T09:31:41.520178Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see 
documentation for more details).
2020-01-17T09:31:43.673005Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-01-17T09:31:43.999679Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-01-17T09:31:44.076853Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generati
ng a new UUID: 2cb67942-390c-11ea-b3c0-0050568de698.
2020-01-17T09:31:44.083281Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-01-17T09:31:44.671140Z 0 [Warning] CA certificate ca.pem is self signed.
2020-01-17T09:31:45.301369Z 1 [Note] A temporary password is generated for root@localhost: dearq:hM1B6p

# 登录mysql
root[/root/Downloads]#mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29

# 设置密码安全策略
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

# 设置密码
mysql> set password='zxxxv81';
Query OK, 0 rows affected (0.00 sec)

4,创建数据库,创建用户,授权

# 创建数据库
mysql> CREATE DATABASE itest CHARACTER SET 'utf8';
Query OK, 1 row affected (0.00 sec)

# 使用数据库itest
mysql> USE itest;
Database changed
# 创建用户itest 失败
mysql> CREATE USER 'itest'@'%' IDENTIFIED BY 'smarttest';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

# 查看密码要求
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password_check_user_name    | OFF    |
| validate_password_dictionary_file    |        |
| validate_password_length             | 5      |
| validate_password_mixed_case_count   | 1      |
| validate_password_number_count       | 1      |
| validate_password_policy             | MEDIUM |
| validate_password_special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.01 sec)

# 设置密码安全策略
mysql>  set global validate_password_policy=LOW;
Query OK, 0 rows affected (0.00 sec)

# 创建用户itest
mysql> CREATE USER 'itest'@'%' IDENTIFIED BY 'smarttest';
Query OK, 0 rows affected (0.00 sec)

# 授权itest数据库给itest用户
mysql> GRANT ALL ON itest.* TO 'itest'@'%' IDENTIFIED BY "smarttest";
Query OK, 0 rows affected, 1 warning (0.00 sec)

# 让授权立刻生效
mysql> FLUSH PRIVILEGES;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值