Yum install and set up MySQL

Source: Internet
Author: User
Tags gpg md5 mysql client uppercase character

Essentially, you set up a Yum source, and then Yum installs it.

However, there are two ways to add a Yum source, one is to create a new/etc/yum.repos.d/mysql-community.repo, and the other is to install the Yum source using the RPM package provided by MySQL. The two are essentially the same.

First Kind

①, New

vim/etc/Yum. Repos.d/mysql-community.repo
②, fill in the content
[Email protected] ~]# vim/etc/Yum. repos.d/mysql-Community.repo [MySQL-connectors-Community]name=MySQL Connectors Communitybaseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/Enabled=1Gpgcheck=1Gpgkey=file:///Etc/pki/rpm-gpg/rpm-gpg-key-mysql[MySQL-tools-Community]name=MySQL Tools Communitybaseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/Enabled=1Gpgcheck=1Gpgkey=file:///Etc/pki/rpm-gpg/rpm-gpg-key-mysql# Enable to use MySQL5.5[Mysql55-Community]name=mysql5.5Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/Enabled=0Gpgcheck=1Gpgkey=file:///Etc/pki/rpm-gpg/rpm-gpg-key-mysql# Enable to use MySQL5.6[Mysql56-Community]name=mysql5.6Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/Enabled=1Gpgcheck=1Gpgkey=file:///Etc/pki/rpm-gpg/rpm-gpg-key-mysql[mysql57-Community]name=mysql5.7Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/Enabled=0Gpgcheck=1Gpgkey=file:///Etc/pki/rpm-gpg/rpm-gpg-key-mysql[mysql80-Community]name=mysql8.0Community Serverbaseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/Enabled=0Gpgcheck=1

Note: If you need to install a version, set the enabled version to 1. The above setting is enabled with version 5.6.

③ clearing the Yum cache

Yum Clean All

④ Updating the Yum cache

Yum Makecache

⑤ installing MySQL

sudo Yum Install Mysql-community-server

⑥ start MySQL

sudo service mysqld start

The second Kind

①, download rpm

Website: https://dev.mysql.com/downloads/repo/yum/

Find the following paragraph and download it as needed. CentOS is the same as red Hat. I'm using CentOS 6.8, so I need to download mysql57-community-release-el6-9.noarch.rpm.

Red Hat Enterprise linux 7/oracle Linux 7 (Architecture Independent), RPM package 9.0K Download
(mysql57-community-release-el7-9.noarch.rpm) MD5: 1a29601dc380ef2c7bc25e2a0e25d31e
Red Hat Enterprise linux 6/oracle Linux 6 (Architecture Independent), RPM package 9.0K Download
(mysql57-community-release-el6-9.noarch.rpm) MD5: 63eb7275f5473a7383c6e929e7ebfb96
Red Hat Enterprise linux 5/oracle Linux 5 (Architecture Independent), RPM package 8.2K Download
(mysql57-community-release-el5-7.noarch.rpm) MD5: 0b141183300cfd0b22c2896f61440554
Fedora (Architecture Independent), RPM package 13.2K Download
(mysql57-community-release-fc25-9.noarch.rpm) MD5: bea9b259f21bd745e70344e3d201f86f
Fedora (Architecture Independent), RPM package 13.1K Download
(mysql57-community-release-fc24-9.noarch.rpm) MD5: 503bf2218267a22425c914c31ab6908c
Fedora (Architecture Independent), RPM package 13.0K Download
(mysql57-community-release-fc23-9.noarch.rpm) MD5: 822d142b5d9e97b22adc8763ccfa62bb

② installation mysql57-community-release-el6-9.noarch.rpm

There's nothing to say.

RPM-IVH mysql57-community-release-el6-9. noarch.rpm

③ Modifying the Yum source for MySQL

The third and subsequent approaches see the first approach, which is exactly the same.

Also, it is important to note that MySQL 5.6 and MySQL 5.7 do not require the same action after installation.

Let's just write it.

For MySQL 5.6, you can use mysql_secure_installation to perform important operations, such as setting the root password, removing anonymous users, and so on.

Note that you should never do this after you install MySQL 5.7 because Yum has already performed this operation!!!

Note that it is important to remember your root password.

Take a look at the official introduction to mysql_secure_installation :

    1. You can set a password for the root account.
    2. You can remove the root account that is accessible from external and local host.
    3. You can remove anonymous accounts.
    4. You can remove the test database (which can be accessed by all users by default-including anonymous accounts), and you can remove permissions that allow anyone to access a database that starts with Test_.

Note: since MySQL 5.7.2,mysql_secure_installation has become an executable binary file that can be used on all platforms. Before that,Mysql_secure_installation was just a script that could only be used on UNIX and unix-like systems.

The general usage is: ① first starts the MySQL Server;② to call mysql_secure_installation directly on localhost.

When executed, it will let you choose what action to perform, as follows.

[[Email protected] ~]# Service mysqld statusmysqld (PID1293) is running ... [[Email protected]~]# mysql_secure_installationnote:running All PARTS of this SCRIPT was RECOMMENDED for all MySQL SERVERS in produc tion Use! Please READ each STEP carefully!in order to log into MySQL to secure it, we'll need the currentPassword forThe root user. If You've just installed MySQL, andYou haven't set the root password yet, the password would be blank,So, should just press ENTER here. Enter Current Password forRoot (enter fornone): OK, successfully used password, moving on ... Setting The root password ensures that nobody can log into the Mysqlroot user without the proper authorisation. Set Root Password? [y/N] ynew password:re-Enter new Password:password updated successfully!Reloading Privilege tables ..... Success!by default, a MySQL installation had an anonymous user, allowing Anyoneto logs into MySQL without had to had a user Account created forthem. this was intended only fortesting, and to MakeThe Installationgo a bit smoother. You should remove them before moving into aproduction environment. Remove Anonymous Users? [y/N] Y ... Success!normally, Root should only is allowed to connect from'localhost'. Thisensures that someone cannot guess at the root of password from the network. Disallow RootLoginRemotely? [y/N] Y ... Success!By default, MySQL comes with a database named'Test'That anyone canaccess. This was also intended only fortesting, and should is removedbefore moving into a production environment. Remove test database and access to it? [y/N] Y-Dropping test database ... ERROR1008(HY000) at line1: Can'T drop database'Test'; database doesn't exist ... Failed!Not critical, keep moving ...-removing privileges on test database ... Success!reloading the privilege tables would ensure that all changes made so farwill take effect immediately. Reload Privilege Tables now? [y/N] Y ... Success! All Done! If You've completed all of the above steps, your MySQLinstallation should now is secure. Thanks forUsing mysql!Cleaning up ... [[Email protected]~]#

Note : Make sure the mysqld is already running.

Initially let you enter the root user's password, if never set, the direct return can:

 for  for None):

If you need to set the root account password, it is advisable to set one, so enter Y and return:

Set root Password? [y/n] Y

Enter the password you want to set, repeat once, two times the same words will prompt the password update success:

new Password:re-Enter new Password:password updated successfully!

Whether you need to delete anonymous users, of course, enter Y and return:

Remove anonymous users? [y/n] Y

Do I need to disable the login of the root account, this depends on the situation, I need, so input y and enter:

Login remotely? [y/n] Y

Whether or not to remove the test database and access to it, you need to enter Y and return:

Remove test database and access to it? [y/n] Y

If you want to reload the permissions table, enter Y and return:

Reload privilege tables now? [y/n] Y

OK, this has been done in MySQL 5.6, you can play happily.

---------------The following is actually the MySQL 5.7.2 after the---------------

In addition, since MySQL 5.7.2,mysql_secure_installation supports these additional features:

    • The Validate_password plugin is used for password strength checking. If it is not installed,mysql_secure_installation will ask the user if it is installed.
    • Most commonly used MySQL client options can --host be --port placed in commands or in option files.

For MySQL 5.7, these actions occur in the background at the first boot after the installation is complete:

    1. Initializes the server.
    2. Generate an SSL authentication and key file in the data directory.
    3. Install and enable Validate_password plugin. The purpose of this plugin is to require that the password contain at least one uppercase character, a lowercase character, a number, and a special one, with a total length of not less than 8 bits.
    4. Created a super User: ‘root‘@‘localhost‘ . Its initial password is stored in the error log file and can be viewed using the following command:
sudo grep ' Temporary password ' /var/log/mysqld.log

Make sure to change the password after the first login!!!

#登录, remember to enter the initial password Shell> Mysql-uroot-P #进入mysql之后就可以更改密码了. MySQL'root'@'localhost'{Your new password} ';

Official website:

https://dev.mysql.com/downloads/repo/yum/

https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

Https://dev.mysql.com/doc/refman/5.7/en/mysql-secure-installation.html

Yum install and set up MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.