centos7安装mysql5

首先要先安装带有可用的mysql5系列社区版资源的rpm包

rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

然后查看可用的mysql安装资源:

[root@hadoop-master hadoop]# yum repolist enabled | grep "mysql.*-community.*"
!mysql-connectors-community/x86_64       MySQL Connectors Community          45
!mysql-tools-community/x86_64            MySQL Tools Community               59
!mysql56-community/x86_64                MySQL 5.6 Community Server         378

(一般来说,只要安装mysql-server跟mysql-client )

直接使用yum的方式安装MySQL

安装完可以进行的操作

1、启动mysql

[root@hadoop-master hadoop]# systemctl start mysqld

2、看安装的mysql

[root@hadoop-master hadoop]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

3、开机启动mysql

[root@hadoop-master hadoop]# systemctl enable mysqld

4、重置密码

最初安装完成后的密码为空

[root@hadoop-master hadoop]# mysql_secure_installation



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

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? [Y/n] 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? [Y/n] 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? [Y/n] y
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - 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? [Y/n] y
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...

5、登录mysql

[root@hadoop-master hadoop]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.6.39 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> 
到此我们就安装好了mysql并成功登陆了。

猜你喜欢

转载自blog.csdn.net/qq_38436939/article/details/79841489
今日推荐