centos安装mysql

centos7系统自带mariadb数据库,先卸载再安装mysql,防止有冲突。

   如果/etc下有my.cnf也卸载掉

  1. 查询是否有安装的mariadb文件

          rpm -qa | grep mariadb   mariadb-libs-5.5.52-1.el7.x86_64

  1. 使用-nodeps 不考虑依赖,强制卸载

 rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

  1. 配置Mysql 8.0安装源:

sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

  1. 安装Mysql 8.0

sudo yum --enablere

  1. 启动Mysql服务

sudo service mysqld start

结果如下,表示成功

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 二 2019-02-19 16:56:11 CST; 4min 1s ago

     Docs: man:mysqld(8)

           http://dev.mysql.com/doc/refman/en/using-systemd.html

  Process: 22953 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

 Main PID: 23048 (mysqld)

   Status: "SERVER_OPERATING"

   CGroup: /system.slice/mysqld.service

           └─23048 /usr/sbin/mysqld

 

2月 19 16:56:02 localhost.localdomain systemd[1]: Starting MySQL Server...

2月 19 16:56:11 localhost.localdomain systemd[1]: Started MySQL Server.

 

  1. 查看root用户临时密码

grep "A temporary password" /var/log/mysqld.log

2019-02-19T08:56:07.061965Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ;q46,&W.v>Ty

如图中q46,&W.v>Ty就是密码

 

  1. 配置Mysql安全策略  设置的密码为#######

mysql_secure_installation

mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:

 ... Failed! Error: Your password does not satisfy the current policy requirements

New password:

Re-enter new password:

The 'validate_password' component is installed on the server.

The subsequent steps will run with the existing configuration

of the component.

Using existing password for root.

Estimated strength of the password: 100

Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:

Re-enter new password:

Estimated strength of the password: 100

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : no

New password:

Re-enter new password:

Estimated strength of the password: 100

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Success.

Normally, root should only be allowed to connect from

'localhost'. This ensures that someone cannot guess at

the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.

By default, MySQL comes with a database named 'test' that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

 - Dropping test database...

Success.

 

 - Removing privileges on test database...

Success.

 

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

 

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

 

  1. 配置远程访问
  1. 登录mysql控制台: mysql -uroot –p#######

mysql -uroot -p#######

2、创建新的远程用户:CREATE USER 'test'@'%' IDENTIFIED BY ' #######';

3、授权给远程用户:GRANT ALL ON *.* TO 'test'@'%';(ALL表示授予所有权限、*.*表示所有数据库中的所有表、%表示任意IP可以远程连接)

其他权限:ALTER、ALTER ROUTINE、CREATE、CREATE ROUTINE、CREATE TABLESPACE、CREATE TEMPORARY TABLES、CREATE USER、CREATE VIEW、DELETE、DROP、EVENT、EXECUTE、FILE、GRANT OPTION、INDEX、INSERT、LOCK TABLES、PROCESS、PROXY、REFERENCES、RELOAD、REPLICATION CLIENT、REPLICATION SLAVE、SELECT、SHOW DATABASES、SHOW VIEW、SHUTDOWN、SUPER、TRIGGER、UPDATE、USAGE。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值