Install MySQL under Linux

Source: Internet
Author: User
Tags uuid mysql login

A Download mysql-5.7.18

    1. Website address: https://dev.mysql.com/downloads/mysql/

2. Download Mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar (RMP file)

Two Install (green area is the command executed on Linux)

1 Uninstall mariadb-lib prior to installation

[Email protected] ~]# Rpm-qa|grep mariadb

Mariadb-libs-5.5.44-2.el7.centos.x86_64

[Email protected] ~]# rpm-e mariadb-libs-5.5.44-2.el7.centos.x86_64--nodeps

2 Go to the official website to download the latest RPM package: Mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar

Extract the Rpm-bundle.tar, actually only need to install the following several packages

[Email protected] ~]# RPM-IVH mysql-community-common-5.7.16-1.el7.x86_64.rpm

[Email protected] ~]# RPM-IVH mysql-community-libs-5.7.16-1.el7.x86_64.rpm

[Email protected] ~]# RPM-IVH mysql-community-client-5.7.16-1.el7.x86_64.rpm

[Email protected] ~]# RPM-IVH mysql-community-server-5.7.16-1.el7.x86_64.rpm

The above several packages have the dependency, the execution has successively.

To install MySQL using the RPM installation, the installation path is as follows:

A database directory
/var/lib/mysql/
B configuration File
/usr/share/mysql (mysql.server command and configuration file)
C Related Commands
/usr/bin (Mysqladmin mysqldump and other commands)
D Startup script
/etc/rc.d/init.d/(startup script file for MySQL directory)

E/etc/my.conf

3 Database Initialization

In order to ensure that the database directory is the owner of the file with the MySQL login user, if you are running the MySQL service as root, you need to perform the following command initialization

[Email protected]~]# mysqld--initialize--user=mysql

If you are running as MySQL, you can remove the--user option.

In addition, the--initialize option is initialized in "safe" mode by default, a password is generated for the root user and the password is marked as expired, and you need to set a new password after logging in.

While using the--initialize-insecure command does not use Safe mode, a password is not generated for the root user.

This demo uses the--initialize initialized, will generate a root account password, the password in the log file, the red area is the auto-generated password

[Email protected] ~]# Cat/var/log/mysqld.log

2017-04-13t10:00:36.294549z0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Use--explicit_defaults_for_timestamp server option (see documentation for Moredetails).

2017-04-13t10:00:36.848923z0 [Warning] innodb:new log files created, lsn=45790

2017-04-13t10:00:36.961351z0 [Warning] innodb:creating FOREIGN KEY constraint system tables.

2017-04-13t10:00:37.153654z0 [Warning] No existing UUID have been found, so we assume it is thefirst time Server has been started. Generating a new uuid:0ae74223-2030-11e7-abde-08002774d86f.

2017-04-13t10:00:37.185725z0 [Warning] Gtid table is not a ready-to-be used. Table ' mysql.gtid_executed ' cannot be opened.

2017-04-13T10:00:37.229524Z1 [Note] A temporary password is generated for [email protected]:%kwtz,ml?3zs

Start MySQL database now systemctl start Mysqld.service

[Email protected] ~]# Systemctlstart Mysqld.service

You can use the following two commands to stop, start, and restart MySQL:

Start:

Start with service: Service mysqld start

Start with mysqld script:/etc/inint.d/mysqld start

Start:safe_mysqld& with Safe_mysqld

Stop it:

Using service startup: Service mysqld stop

Start with mysqld script:/etc/inint.d/mysqld stop

Mysqladminshutdown

Restart:

Using service startup: Service mysqld restart

Start with mysqld script:/etc/inint.d/mysqld restart

Connecting to a database

[Email protected] ~]# mysql-u root-p

Enter Password:

Password Input:%kwtz,ml?3zs

Change Password:

Mysql> ALTER USER ' root ' @ ' localhost ' identified by ' new_password ';

Because my Linux centos7 is installed on the virtual machine, I need to use the host remote access to MySQL, the connection to MySQL 1045 error occurred.

Workaround:

Mysql> Usemysql;

Mysql> selecthost,user from user;

Need to re-edit:

Linux connection MySQL 1045 Error resolution
Get the following results +---------------+------+| Host | user | +---------------+------+ | localhost | Root |+---------------+------+ 5 rows in Set (0.00 sec)

The root user was found to only allow local (localhost) logins

, if you want to telnet to the MySQL server, you need to create a new user with normal permissions, the new user uses the following command:

Mysql> Grant Select,update,insert,delete onmas.* to [e-mail protected] identified by "123456";

This command means: Create a new user Duan and only allow the user to log on locally (localhost), the password is 123456, and give it permission to select,update,insert all tables in the MAS library. We have a MAS library here, so we use mas.* to represent all the tables under the MAS library. Now the Duan user, can log in to MySQL, but also can only log on locally.

To Duan users to telnet to MySQL, you also need the following command:

mysql> Update user Set host = '% ' Whereuser = ' Duan ';

Now let's look at the MySQL Admin library:

Mysql> Select Host,user from user;+-----------+------+ | Host | user | +-----------+------+ | % | Duan | |localhost | Root | +-----------+------+ 5 rows in Set (0.00 sec) At this point, create a new connection on Mysql-front, enter the connection name, the remote Linux IP address, enter the user name Duan and password 123456, select the connection port, MySQL default is 3306, or the connection is not on.

After many searches, it was found that it was necessary to perform

Mysql> flushprivileges;

After I flush the cache, I'm finally done. Because the UPDATE statement is used to modify user records, the flush statement is also required to tell the server to overload the authorization table. When you use the GRANT and REVOKE statements, the table is automatically overloaded, not when you modify the authorization table directly. So the easier way is mysql> grant Select,update,insert,delete on mas.*to [email protected] "%" identified by "123456";

Install MySQL under Linux

Related Article

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.